Merge branch 'develop' of github.com:annando/friendica into 1409-shadow-items
This commit is contained in:
commit
a3f7578085
1188 changed files with 155683 additions and 158969 deletions
|
@ -12,7 +12,7 @@ Deny from all
|
|||
# Protect repository directory from browsing
|
||||
RewriteRule "(^|/)\.git" - [F]
|
||||
|
||||
# Rewrite current-style URLs of the form 'index.php?q=x'.
|
||||
# Rewrite current-style URLs of the form 'index.php?pagename=x'.
|
||||
# Also place auth information into REMOTE_USER for sites running
|
||||
# in CGI mode.
|
||||
|
||||
|
@ -28,7 +28,7 @@ Deny from all
|
|||
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule ^(.*)$ index.php?q=$1 [E=REMOTE_USER:%{HTTP:Authorization},L,QSA]
|
||||
RewriteRule ^(.*)$ index.php?pagename=$1 [E=REMOTE_USER:%{HTTP:Authorization},L,QSA]
|
||||
|
||||
</IfModule>
|
||||
|
||||
|
|
29
CHANGELOG
Normal file
29
CHANGELOG
Normal file
|
@ -0,0 +1,29 @@
|
|||
Version 3.3.1
|
||||
|
||||
JSONP support for API (fabrixxm)
|
||||
Fixed small bug in direct messages API (fabrixxm)
|
||||
More filter for direct messages API (fabrixxm)
|
||||
New hooks "getsiteinfo", "page_info_data" (annando)
|
||||
Better loop post prevention (annando)
|
||||
Via API, replace data: uri images in plain text version with link to post. (issue #1134) (fabrixxm)
|
||||
Set default location to empty for new users. Suppress warning on user creation (issue #1193) (fabrixxm)
|
||||
Correctly build urls with queries (issue #1190) (fabrixxm)
|
||||
Optionally use keywords in feed as post tags with "remote self" (annando)
|
||||
A blacklist of keywords to not use can be defined (annando)
|
||||
"remote self" works also with Friendica and Diaspora contacts (annando)
|
||||
Show exact post time after 12 hours (FX7)
|
||||
Optionally redirect from non-SSL to SSL (annando)
|
||||
Translation updates
|
||||
Added CHANGELOG
|
||||
|
||||
Version 3.3
|
||||
|
||||
See http://friendica.com/node/64
|
||||
|
||||
Version 3.2
|
||||
|
||||
See http://friendica.com/node/61
|
||||
|
||||
Version 3.1
|
||||
|
||||
See http://friendica.com/node/58
|
228
Vagrantfile
vendored
228
Vagrantfile
vendored
|
@ -1,78 +1,21 @@
|
|||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
# Config Github Settings
|
||||
github_username = "fideloper"
|
||||
github_repo = "Vaprobash"
|
||||
github_branch = "1.0.0"
|
||||
github_url = "https://raw.githubusercontent.com/#{github_username}/#{github_repo}/#{github_branch}"
|
||||
|
||||
# Server Configuration
|
||||
|
||||
hostname = "vaprobash.dev"
|
||||
|
||||
# Set a local private network IP address.
|
||||
# See http://en.wikipedia.org/wiki/Private_network for explanation
|
||||
# You can use the following IP ranges:
|
||||
# 10.0.0.1 - 10.255.255.254
|
||||
# 172.16.0.1 - 172.31.255.254
|
||||
# 192.168.0.1 - 192.168.255.254
|
||||
server_ip = "192.168.22.10"
|
||||
server_memory = "384" # MB
|
||||
server_swap = "768" # Options: false | int (MB) - Guideline: Between one or two times the server_memory
|
||||
server_timezone = "UTC"
|
||||
|
||||
# Database Configuration
|
||||
mysql_root_password = "root" # We'll assume user "root"
|
||||
mysql_version = "5.5" # Options: 5.5 | 5.6
|
||||
mysql_enable_remote = "false" # remote access enabled when true
|
||||
pgsql_root_password = "root" # We'll assume user "root"
|
||||
|
||||
# Languages and Packages6
|
||||
ruby_version = "latest" # Choose what ruby version should be installed (will also be the default version)
|
||||
ruby_gems = [ # List any Ruby Gems that you want to install
|
||||
#"jekyll",
|
||||
#"sass",
|
||||
#"compass",
|
||||
]
|
||||
|
||||
# To install HHVM instead of PHP, set this to "true"
|
||||
hhvm = "false"
|
||||
|
||||
# PHP Options
|
||||
composer_packages = [ # List any global Composer packages that you want to install
|
||||
#"phpunit/phpunit:4.0.*",
|
||||
#"codeception/codeception=*",
|
||||
#"phpspec/phpspec:2.0.*@dev",
|
||||
#"squizlabs/php_codesniffer:1.5.*",
|
||||
]
|
||||
|
||||
# Default web server document root
|
||||
# Symfony's public directory is assumed "web"
|
||||
# Laravel's public directory is assumed "public"
|
||||
public_folder = "/vagrant"
|
||||
|
||||
laravel_root_folder = "/vagrant/laravel" # Where to install Laravel. Will `composer install` if a composer.json file exists
|
||||
laravel_version = "latest-stable" # If you need a specific version of Laravel, set it here
|
||||
symfony_root_folder = "/vagrant/symfony" # Where to install Symfony.
|
||||
|
||||
nodejs_version = "latest" # By default "latest" will equal the latest stable version
|
||||
nodejs_packages = [ # List any global NodeJS packages that you want to install
|
||||
#"grunt-cli",
|
||||
#"gulp",
|
||||
#"bower",
|
||||
#"yo",
|
||||
]
|
||||
public_folder = "/vagrant"
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
|
||||
# Set server to Ubuntu 14.04
|
||||
config.vm.box = "ubuntu/trusty64"
|
||||
# Set server to Ubuntu 12.04
|
||||
config.vm.box = "precise64"
|
||||
|
||||
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
|
||||
|
||||
# Create a hostname, don't forget to put it to the `hosts` file
|
||||
# This will point to the server's default virtual host
|
||||
# TO DO: Make this work with virtualhost along-side xip.io URL
|
||||
config.vm.hostname = hostname
|
||||
config.vm.hostname = "friendica.dev"
|
||||
|
||||
# Create a static IP
|
||||
config.vm.network :private_network, ip: server_ip
|
||||
|
@ -89,175 +32,28 @@ Vagrant.configure("2") do |config|
|
|||
vb.customize ["guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 10000]
|
||||
|
||||
# Prevent VMs running on Ubuntu to lose internet connection
|
||||
# vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
|
||||
# vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
|
||||
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
|
||||
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
|
||||
|
||||
end
|
||||
|
||||
# If using VMWare Fusion
|
||||
config.vm.provider "vmware_fusion" do |vb, override|
|
||||
override.vm.box_url = "http://files.vagrantup.com/precise64_vmware.box"
|
||||
|
||||
|
||||
# Set server memory
|
||||
vb.vmx["memsize"] = server_memory
|
||||
|
||||
end
|
||||
|
||||
# If using Vagrant-Cachier
|
||||
# http://fgrehm.viewdocs.io/vagrant-cachier
|
||||
if Vagrant.has_plugin?("vagrant-cachier")
|
||||
# Configure cached packages to be shared between instances of the same base box.
|
||||
# Usage docs: http://fgrehm.viewdocs.io/vagrant-cachier/usage
|
||||
config.cache.scope = :box
|
||||
|
||||
config.cache.synced_folder_opts = {
|
||||
type: :nfs,
|
||||
mount_options: ['rw', 'vers=3', 'tcp', 'nolock']
|
||||
}
|
||||
end
|
||||
|
||||
####
|
||||
# Base Items
|
||||
##########
|
||||
|
||||
# Provision Base Packages
|
||||
config.vm.provision "shell", path: "#{github_url}/scripts/base.sh", args: [github_url, server_swap]
|
||||
|
||||
# Provision PHP
|
||||
config.vm.provision "shell", path: "#{github_url}/scripts/php.sh", args: [server_timezone, hhvm]
|
||||
|
||||
# Enable MSSQL for PHP
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/mssql.sh"
|
||||
|
||||
# Provision Vim
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/vim.sh", args: github_url
|
||||
|
||||
|
||||
####
|
||||
# Web Servers
|
||||
##########
|
||||
|
||||
# Provision Apache Base
|
||||
config.vm.provision "shell", path: "#{github_url}/scripts/apache.sh", args: [server_ip, public_folder, hostname, github_url]
|
||||
|
||||
# Provision Nginx Base
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/nginx.sh", args: [server_ip, public_folder, hostname, github_url]
|
||||
|
||||
|
||||
####
|
||||
# Databases
|
||||
##########
|
||||
|
||||
# Provision MySQL
|
||||
config.vm.provision "shell", path: "#{github_url}/scripts/mysql.sh", args: [mysql_root_password, mysql_version, mysql_enable_remote]
|
||||
|
||||
# Provision PostgreSQL
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/pgsql.sh", args: pgsql_root_password
|
||||
|
||||
# Provision SQLite
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/sqlite.sh"
|
||||
|
||||
# Provision RethinkDB
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/rethinkdb.sh", args: pgsql_root_password
|
||||
|
||||
# Provision Couchbase
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/couchbase.sh"
|
||||
|
||||
# Provision CouchDB
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/couchdb.sh"
|
||||
|
||||
# Provision MongoDB
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/mongodb.sh"
|
||||
|
||||
# Provision MariaDB
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/mariadb.sh", args: [mysql_root_password, mysql_enable_remote]
|
||||
|
||||
####
|
||||
# Search Servers
|
||||
##########
|
||||
|
||||
# Install Elasticsearch
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/elasticsearch.sh"
|
||||
|
||||
# Install SphinxSearch
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/sphinxsearch.sh"
|
||||
|
||||
####
|
||||
# Search Server Administration (web-based)
|
||||
##########
|
||||
|
||||
# Install ElasticHQ
|
||||
# Admin for: Elasticsearch
|
||||
# Works on: Apache2, Nginx
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/elastichq.sh"
|
||||
|
||||
|
||||
####
|
||||
# In-Memory Stores
|
||||
##########
|
||||
|
||||
# Install Memcached
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/memcached.sh"
|
||||
|
||||
# Provision Redis (without journaling and persistence)
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/redis.sh"
|
||||
|
||||
# Provision Redis (with journaling and persistence)
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/redis.sh", args: "persistent"
|
||||
# NOTE: It is safe to run this to add persistence even if originally provisioned without persistence
|
||||
|
||||
|
||||
####
|
||||
# Utility (queue)
|
||||
##########
|
||||
|
||||
# Install Beanstalkd
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/beanstalkd.sh"
|
||||
|
||||
# Install Heroku Toolbelt
|
||||
# config.vm.provision "shell", path: "https://toolbelt.heroku.com/install-ubuntu.sh"
|
||||
|
||||
# Install Supervisord
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/supervisord.sh"
|
||||
|
||||
####
|
||||
# Additional Languages
|
||||
##########
|
||||
|
||||
# Install Nodejs
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/nodejs.sh", privileged: false, args: nodejs_packages.unshift(nodejs_version, github_url)
|
||||
|
||||
# Install Ruby Version Manager (RVM)
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/rvm.sh", privileged: false, args: ruby_gems.unshift(ruby_version)
|
||||
|
||||
####
|
||||
# Frameworks and Tooling
|
||||
##########
|
||||
|
||||
# Provision Composer
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/composer.sh", privileged: false, args: composer_packages.join(" ")
|
||||
|
||||
# Provision Laravel
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/laravel.sh", privileged: false, args: [server_ip, laravel_root_folder, public_folder, laravel_version]
|
||||
|
||||
# Provision Symfony
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/symfony.sh", privileged: false, args: [server_ip, symfony_root_folder, public_folder]
|
||||
|
||||
# Install Screen
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/screen.sh"
|
||||
|
||||
# Install config Mailcatcher
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/mailcatcher.sh"
|
||||
|
||||
# Install git-ftp
|
||||
# config.vm.provision "shell", path: "#{github_url}/scripts/git-ftp.sh", privileged: false
|
||||
|
||||
|
||||
####
|
||||
# Local Scripts
|
||||
# Any local scripts you may want to run post-provisioning.
|
||||
# Add these to the same directory as the Vagrantfile.
|
||||
##########
|
||||
config.vm.provision "shell", path: "./util/vagrant_provision.sh"
|
||||
|
||||
config.vm.synced_folder "./", "/vagrant/", :owner=> 'www-data', :group=>'vagrant', :mount_options => ['dmode=775', 'fmode=775']
|
||||
config.vm.provision "shell", path: "./util/vagrant_provision.sh"
|
||||
|
||||
end
|
||||
|
|
269
boot.php
269
boot.php
|
@ -11,10 +11,14 @@ require_once('include/cache.php');
|
|||
require_once('library/Mobile_Detect/Mobile_Detect.php');
|
||||
require_once('include/features.php');
|
||||
|
||||
require_once('update.php');
|
||||
require_once('include/dbstructure.php');
|
||||
|
||||
define ( 'FRIENDICA_PLATFORM', 'Friendica');
|
||||
define ( 'FRIENDICA_VERSION', '3.2.1753' );
|
||||
define ( 'FRIENDICA_CODENAME', 'Ginger');
|
||||
define ( 'FRIENDICA_VERSION', '3.3.1' );
|
||||
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
|
||||
define ( 'DB_UPDATE_VERSION', 1173 );
|
||||
define ( 'DB_UPDATE_VERSION', 1175 );
|
||||
define ( 'EOL', "<br />\r\n" );
|
||||
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
|
||||
|
||||
|
@ -505,27 +509,41 @@ if(! class_exists('App')) {
|
|||
$argc --;
|
||||
}
|
||||
|
||||
set_include_path("include/$this->hostname" . PATH_SEPARATOR . get_include_path());
|
||||
#set_include_path("include/$this->hostname" . PATH_SEPARATOR . get_include_path());
|
||||
|
||||
if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") {
|
||||
if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,9) === "pagename=") {
|
||||
$this->query_string = substr($_SERVER['QUERY_STRING'],9);
|
||||
// removing trailing / - maybe a nginx problem
|
||||
if (substr($this->query_string, 0, 1) == "/")
|
||||
$this->query_string = substr($this->query_string, 1);
|
||||
} elseif((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") {
|
||||
$this->query_string = substr($_SERVER['QUERY_STRING'],2);
|
||||
// removing trailing / - maybe a nginx problem
|
||||
if (substr($this->query_string, 0, 1) == "/")
|
||||
$this->query_string = substr($this->query_string, 1);
|
||||
}
|
||||
if(x($_GET,'q'))
|
||||
|
||||
if (x($_GET,'pagename'))
|
||||
$this->cmd = trim($_GET['pagename'],'/\\');
|
||||
elseif (x($_GET,'q'))
|
||||
$this->cmd = trim($_GET['q'],'/\\');
|
||||
|
||||
|
||||
// fix query_string
|
||||
$this->query_string = str_replace($this->cmd."&",$this->cmd."?", $this->query_string);
|
||||
|
||||
|
||||
// unix style "homedir"
|
||||
|
||||
if(substr($this->cmd,0,1) === '~')
|
||||
$this->cmd = 'profile/' . substr($this->cmd,1);
|
||||
$this->cmd = 'profile/' . substr($this->cmd,1);
|
||||
|
||||
// Diaspora style profile url
|
||||
|
||||
if(substr($this->cmd,0,2) === 'u/')
|
||||
$this->cmd = 'profile/' . substr($this->cmd,2);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Break the URL path into C style argc/argv style arguments for our
|
||||
|
@ -598,6 +616,10 @@ if(! class_exists('App')) {
|
|||
return($basepath);
|
||||
}
|
||||
|
||||
function get_scheme() {
|
||||
return($this->scheme);
|
||||
}
|
||||
|
||||
function get_baseurl($ssl = false) {
|
||||
|
||||
$scheme = $this->scheme;
|
||||
|
@ -617,6 +639,9 @@ if(! class_exists('App')) {
|
|||
}
|
||||
}
|
||||
|
||||
if (get_config('config','hostname') != "")
|
||||
$this->hostname = get_config('config','hostname');
|
||||
|
||||
$this->baseurl = $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' );
|
||||
return $this->baseurl;
|
||||
}
|
||||
|
@ -638,12 +663,19 @@ if(! class_exists('App')) {
|
|||
if (file_exists(".htpreconfig.php"))
|
||||
@include(".htpreconfig.php");
|
||||
|
||||
$this->hostname = $hostname;
|
||||
if (get_config('config','hostname') != "")
|
||||
$this->hostname = get_config('config','hostname');
|
||||
|
||||
if (!isset($this->hostname) OR ($this->hostname == ""))
|
||||
$this->hostname = $hostname;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function get_hostname() {
|
||||
if (get_config('config','hostname') != "")
|
||||
$this->hostname = get_config('config','hostname');
|
||||
|
||||
return $this->hostname;
|
||||
}
|
||||
|
||||
|
@ -789,7 +821,7 @@ if(! class_exists('App')) {
|
|||
}
|
||||
if ($name===""){
|
||||
echo "template engine <tt>$class</tt> cannot be registered without a name.\n";
|
||||
killme();
|
||||
killme();
|
||||
}
|
||||
$this->template_engines[$name] = $class;
|
||||
}
|
||||
|
@ -797,7 +829,7 @@ if(! class_exists('App')) {
|
|||
/**
|
||||
* return template engine instance. If $name is not defined,
|
||||
* return engine defined by theme, or default
|
||||
*
|
||||
*
|
||||
* @param strin $name Template engine name
|
||||
* @return object Template Engine instance
|
||||
*/
|
||||
|
@ -865,6 +897,10 @@ if(! class_exists('App')) {
|
|||
$this->performance["markstart"] = microtime(true) - $this->performance["markstart"] - $this->performance["marktime"];
|
||||
}
|
||||
|
||||
function get_useragent() {
|
||||
return(FRIENDICA_PLATFORM." '".FRIENDICA_CODENAME."' ".FRIENDICA_VERSION."-".DB_UPDATE_VERSION."; ".$this->get_baseurl());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -992,7 +1028,6 @@ if(! function_exists('check_url')) {
|
|||
|
||||
if(! function_exists('update_db')) {
|
||||
function update_db(&$a) {
|
||||
|
||||
$build = get_config('system','build');
|
||||
if(! x($build))
|
||||
$build = set_config('system','build',DB_UPDATE_VERSION);
|
||||
|
@ -1000,99 +1035,51 @@ if(! function_exists('update_db')) {
|
|||
if($build != DB_UPDATE_VERSION) {
|
||||
$stored = intval($build);
|
||||
$current = intval(DB_UPDATE_VERSION);
|
||||
if(($stored < $current) && file_exists('update.php')) {
|
||||
|
||||
if($stored < $current) {
|
||||
load_config('database');
|
||||
|
||||
// We're reporting a different version than what is currently installed.
|
||||
// Run any existing update scripts to bring the database up to current.
|
||||
|
||||
require_once('update.php');
|
||||
|
||||
// make sure that boot.php and update.php are the same release, we might be
|
||||
// updating right this very second and the correct version of the update.php
|
||||
// file may not be here yet. This can happen on a very busy site.
|
||||
|
||||
if(DB_UPDATE_VERSION == UPDATE_VERSION) {
|
||||
|
||||
// Compare the current structure with the defined structure
|
||||
|
||||
$t = get_config('database','dbupdate_'.DB_UPDATE_VERSION);
|
||||
if($t !== false)
|
||||
break;
|
||||
return;
|
||||
|
||||
set_config('database','dbupdate_'.DB_UPDATE_VERSION, time());
|
||||
|
||||
require_once("include/dbstructure.php");
|
||||
// run old update routine (wich could modify the schema and
|
||||
// conflits with new routine)
|
||||
for ($x = $stored; $x < NEW_UPDATE_ROUTINE_VERSION; $x++) {
|
||||
$r = run_update_function($x);
|
||||
if (!$r) break;
|
||||
}
|
||||
if ($stored < NEW_UPDATE_ROUTINE_VERSION) $stored = NEW_UPDATE_ROUTINE_VERSION;
|
||||
|
||||
|
||||
// run new update routine
|
||||
// it update the structure in one call
|
||||
$retval = update_structure(false, true);
|
||||
if($retval) {
|
||||
//send the administrator an e-mail
|
||||
$email_tpl = get_intltext_template("update_fail_eml.tpl");
|
||||
$email_msg = replace_macros($email_tpl, array(
|
||||
'$sitename' => $a->config['sitename'],
|
||||
'$siteurl' => $a->get_baseurl(),
|
||||
'$update' => DB_UPDATE_VERSION,
|
||||
'$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
|
||||
));
|
||||
$subject=sprintf(t('Update Error at %s'), $a->get_baseurl());
|
||||
require_once('include/email.php');
|
||||
$subject = email_header_encode($subject,'UTF-8');
|
||||
mail($a->config['admin_email'], $subject, $email_msg,
|
||||
'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n"
|
||||
.'Content-type: text/plain; charset=UTF-8'."\n"
|
||||
.'Content-transfer-encoding: 8bit');
|
||||
//try the logger
|
||||
logger("CRITICAL: Database structure update failed: ".$retval);
|
||||
break;
|
||||
} else
|
||||
update_fail(
|
||||
DB_UPDATE_VERSION,
|
||||
$retval
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
set_config('database','dbupdate_'.DB_UPDATE_VERSION, 'success');
|
||||
}
|
||||
|
||||
// run any left update_nnnn functions in update.php
|
||||
for($x = $stored; $x < $current; $x ++) {
|
||||
if(function_exists('update_' . $x)) {
|
||||
|
||||
// There could be a lot of processes running or about to run.
|
||||
// We want exactly one process to run the update command.
|
||||
// So store the fact that we're taking responsibility
|
||||
// after first checking to see if somebody else already has.
|
||||
|
||||
// If the update fails or times-out completely you may need to
|
||||
// delete the config entry to try again.
|
||||
|
||||
$t = get_config('database','update_' . $x);
|
||||
if($t !== false)
|
||||
break;
|
||||
set_config('database','update_' . $x, time());
|
||||
|
||||
// call the specific update
|
||||
|
||||
$func = 'update_' . $x;
|
||||
$retval = $func();
|
||||
if($retval) {
|
||||
//send the administrator an e-mail
|
||||
$email_tpl = get_intltext_template("update_fail_eml.tpl");
|
||||
$email_msg = replace_macros($email_tpl, array(
|
||||
'$sitename' => $a->config['sitename'],
|
||||
'$siteurl' => $a->get_baseurl(),
|
||||
'$update' => $x,
|
||||
'$error' => sprintf( t('Update %s failed. See error logs.'), $x)
|
||||
));
|
||||
$subject=sprintf(t('Update Error at %s'), $a->get_baseurl());
|
||||
require_once('include/email.php');
|
||||
$subject = email_header_encode($subject,'UTF-8');
|
||||
mail($a->config['admin_email'], $subject, $email_msg,
|
||||
'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n"
|
||||
. 'Content-type: text/plain; charset=UTF-8' . "\n"
|
||||
. 'Content-transfer-encoding: 8bit' );
|
||||
//try the logger
|
||||
logger('CRITICAL: Update Failed: '. $x);
|
||||
break;
|
||||
} else {
|
||||
set_config('database','update_' . $x, 'success');
|
||||
set_config('system','build', $x + 1);
|
||||
}
|
||||
} else {
|
||||
set_config('database','update_' . $x, 'success');
|
||||
set_config('system','build', $x + 1);
|
||||
}
|
||||
$r = run_update_function($x);
|
||||
if (!$r) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1101,6 +1088,48 @@ if(! function_exists('update_db')) {
|
|||
return;
|
||||
}
|
||||
}
|
||||
if(!function_exists('run_update_function')){
|
||||
function run_update_function($x) {
|
||||
if(function_exists('update_' . $x)) {
|
||||
|
||||
// There could be a lot of processes running or about to run.
|
||||
// We want exactly one process to run the update command.
|
||||
// So store the fact that we're taking responsibility
|
||||
// after first checking to see if somebody else already has.
|
||||
|
||||
// If the update fails or times-out completely you may need to
|
||||
// delete the config entry to try again.
|
||||
|
||||
$t = get_config('database','update_' . $x);
|
||||
if($t !== false)
|
||||
return false;
|
||||
set_config('database','update_' . $x, time());
|
||||
|
||||
// call the specific update
|
||||
|
||||
$func = 'update_' . $x;
|
||||
$retval = $func();
|
||||
|
||||
if($retval) {
|
||||
//send the administrator an e-mail
|
||||
update_fail(
|
||||
$x,
|
||||
sprintf(t('Update %s failed. See error logs.'), $x)
|
||||
);
|
||||
return false;
|
||||
} else {
|
||||
set_config('database','update_' . $x, 'success');
|
||||
set_config('system','build', $x + 1);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
set_config('database','update_' . $x, 'success');
|
||||
set_config('system','build', $x + 1);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(! function_exists('check_plugins')) {
|
||||
|
@ -1209,7 +1238,7 @@ if(! function_exists('login')) {
|
|||
}
|
||||
|
||||
$noid = get_config('system','no_openid');
|
||||
|
||||
|
||||
$dest_url = $a->get_baseurl(true) . '/' . $a->query_string;
|
||||
|
||||
if(local_user()) {
|
||||
|
@ -1230,18 +1259,18 @@ if(! function_exists('login')) {
|
|||
'$dest_url' => $dest_url,
|
||||
'$logout' => t('Logout'),
|
||||
'$login' => t('Login'),
|
||||
|
||||
|
||||
'$lname' => array('username', t('Nickname or Email address: ') , '', ''),
|
||||
'$lpassword' => array('password', t('Password: '), '', ''),
|
||||
'$lremember' => array('remember', t('Remember me'), 0, ''),
|
||||
|
||||
|
||||
'$openid' => !$noid,
|
||||
'$lopenid' => array('openid_url', t('Or login using OpenID: '),'',''),
|
||||
|
||||
|
||||
'$hiddens' => $hiddens,
|
||||
|
||||
|
||||
'$register' => $reg,
|
||||
|
||||
|
||||
'$lostpass' => t('Forgot your password?'),
|
||||
'$lostlink' => t('Password Reset'),
|
||||
|
||||
|
@ -1304,9 +1333,9 @@ if(! function_exists('remote_user')) {
|
|||
if(! function_exists('notice')) {
|
||||
/**
|
||||
* Show an error message to user.
|
||||
*
|
||||
*
|
||||
* This function save text in session, to be shown to the user at next page load
|
||||
*
|
||||
*
|
||||
* @param string $s - Text of notice
|
||||
*/
|
||||
function notice($s) {
|
||||
|
@ -1319,9 +1348,9 @@ if(! function_exists('notice')) {
|
|||
if(! function_exists('info')) {
|
||||
/**
|
||||
* Show an info message to user.
|
||||
*
|
||||
*
|
||||
* This function save text in session, to be shown to the user at next page load
|
||||
*
|
||||
*
|
||||
* @param string $s - Text of notice
|
||||
*/
|
||||
function info($s) {
|
||||
|
@ -1745,7 +1774,7 @@ if(! function_exists('get_birthdays')) {
|
|||
$rr['date'] = day_translate(datetime_convert('UTC', $a->timezone, $rr['start'], $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . t('[today]') : '');
|
||||
$rr['startime'] = Null;
|
||||
$rr['today'] = $today;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1820,7 +1849,7 @@ if(! function_exists('get_events')) {
|
|||
|
||||
$strt = datetime_convert('UTC',$rr['convert'] ? $a->timezone : 'UTC',$rr['start']);
|
||||
$today = ((substr($strt,0,10) === datetime_convert('UTC',$a->timezone,'now','Y-m-d')) ? true : false);
|
||||
|
||||
|
||||
$rr['link'] = $md;
|
||||
$rr['title'] = $title;
|
||||
$rr['date'] = day_translate(datetime_convert('UTC', $rr['adjust'] ? $a->timezone : 'UTC', $rr['start'], $bd_format)) . (($today) ? ' ' . t('[today]') : '');
|
||||
|
@ -1880,7 +1909,7 @@ if(! function_exists('proc_run')) {
|
|||
}
|
||||
|
||||
$args = $newargs;
|
||||
|
||||
|
||||
$arr = array('args' => $args, 'run_cmd' => true);
|
||||
|
||||
call_hooks("proc_run", $arr);
|
||||
|
@ -1889,14 +1918,14 @@ if(! function_exists('proc_run')) {
|
|||
|
||||
if(count($args) && $args[0] === 'php')
|
||||
$args[0] = ((x($a->config,'php_path')) && (strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
|
||||
|
||||
|
||||
// add baseurl to args. cli scripts can't construct it
|
||||
$args[] = $a->get_baseurl();
|
||||
|
||||
|
||||
for($x = 0; $x < count($args); $x ++)
|
||||
$args[$x] = escapeshellarg($args[$x]);
|
||||
|
||||
|
||||
|
||||
|
||||
$cmdline = implode($args," ");
|
||||
if(get_config('system','proc_windows'))
|
||||
|
@ -1909,9 +1938,9 @@ if(! function_exists('proc_run')) {
|
|||
if(! function_exists('current_theme')) {
|
||||
function current_theme(){
|
||||
$app_base_themes = array('duepuntozero', 'dispy', 'quattro');
|
||||
|
||||
|
||||
$a = get_app();
|
||||
|
||||
|
||||
// $mobile_detect = new Mobile_Detect();
|
||||
// $is_mobile = $mobile_detect->isMobile() || $mobile_detect->isTablet();
|
||||
$is_mobile = $a->is_mobile || $a->is_tablet;
|
||||
|
@ -1941,17 +1970,17 @@ if(! function_exists('current_theme')) {
|
|||
(file_exists('view/theme/' . $theme_name . '/style.css') ||
|
||||
file_exists('view/theme/' . $theme_name . '/style.php')))
|
||||
return($theme_name);
|
||||
|
||||
|
||||
foreach($app_base_themes as $t) {
|
||||
if(file_exists('view/theme/' . $t . '/style.css')||
|
||||
file_exists('view/theme/' . $t . '/style.php'))
|
||||
return($t);
|
||||
}
|
||||
|
||||
|
||||
$fallback = array_merge(glob('view/theme/*/style.css'),glob('view/theme/*/style.php'));
|
||||
if(count($fallback))
|
||||
return (str_replace('view/theme/','', substr($fallback[0],0,-10)));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1991,7 +2020,7 @@ if(! function_exists('feed_birthday')) {
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
$birthday = '';
|
||||
|
||||
if(! strlen($tz))
|
||||
|
@ -2061,13 +2090,13 @@ if(! function_exists('load_contact_links')) {
|
|||
if(! function_exists('profile_tabs')){
|
||||
function profile_tabs($a, $is_owner=False, $nickname=Null){
|
||||
//echo "<pre>"; var_dump($a->user); killme();
|
||||
|
||||
|
||||
if (is_null($nickname))
|
||||
$nickname = $a->user['nickname'];
|
||||
|
||||
|
||||
if(x($_GET,'tab'))
|
||||
$tab = notags(trim($_GET['tab']));
|
||||
|
||||
|
||||
$url = $a->get_baseurl() . '/profile/' . $nickname;
|
||||
|
||||
$tabs = array(
|
||||
|
@ -2100,7 +2129,7 @@ if(! function_exists('profile_tabs')){
|
|||
'id' => 'video-tab',
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
if ($is_owner){
|
||||
$tabs[] = array(
|
||||
'label' => t('Events'),
|
||||
|
@ -2121,7 +2150,7 @@ if(! function_exists('profile_tabs')){
|
|||
|
||||
$arr = array('is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => (($tab) ? $tab : false), 'tabs' => $tabs);
|
||||
call_hooks('profile_tabs', $arr);
|
||||
|
||||
|
||||
$tpl = get_markup_template('common_tabs.tpl');
|
||||
|
||||
return replace_macros($tpl,array('$tabs' => $arr['tabs']));
|
||||
|
@ -2160,28 +2189,28 @@ function zrl($s,$force = false) {
|
|||
/**
|
||||
* returns querystring as string from a mapped array
|
||||
*
|
||||
* @param params Array
|
||||
* @param params Array
|
||||
* @return string
|
||||
*/
|
||||
function build_querystring($params, $name=null) {
|
||||
$ret = "";
|
||||
function build_querystring($params, $name=null) {
|
||||
$ret = "";
|
||||
foreach($params as $key=>$val) {
|
||||
if(is_array($val)) {
|
||||
if(is_array($val)) {
|
||||
if($name==null) {
|
||||
$ret .= build_querystring($val, $key);
|
||||
$ret .= build_querystring($val, $key);
|
||||
} else {
|
||||
$ret .= build_querystring($val, $name."[$key]");
|
||||
$ret .= build_querystring($val, $name."[$key]");
|
||||
}
|
||||
} else {
|
||||
$val = urlencode($val);
|
||||
if($name!=null) {
|
||||
$ret.=$name."[$key]"."=$val&";
|
||||
$ret.=$name."[$key]"."=$val&";
|
||||
} else {
|
||||
$ret.= "$key=$val&";
|
||||
$ret.= "$key=$val&";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function explode_querystring($query) {
|
||||
|
|
31
doc/FAQ.md
31
doc/FAQ.md
|
@ -12,6 +12,7 @@ User
|
|||
* **[What happens when an account is removed? Is it truly deleted?](help/FAQ#removed)**
|
||||
* **[Can I subscribe to a hashtag?](help/FAQ#hashtag)**
|
||||
* **[How to create a RSS feed of the stream?](help/FAQ#rss)**
|
||||
* **[Are there any clients for friendica I can use?](help/FAQ#clients)**
|
||||
* **[Where I can find help?](help/FAQ#help)**
|
||||
|
||||
Admins
|
||||
|
@ -39,7 +40,6 @@ Sometimes you get a browser warning about a missing certificate. These warnings
|
|||
If you dont have a SSL cert yet, there are three ways to get one: buy one, get a free one (eg. via StartSSL) or create your own (not recommended). [You can find more information about setting up SSL and why it's a bad idea to use self-signed SSL here.](help/SSL)
|
||||
|
||||
Be aware that a browser warning about security issues is something that can make new users feel insecure about the whole friendica project.
|
||||
Because of this, Friendica Red will only accept SSL certs signed by a recognized CA and doesn't connect to servers without these kind of SSL. Despite of the negative aspects of SSL, this is a necessary solution until there is an established alternative for this technique.
|
||||
|
||||
Also you can have problems with the connection to diaspora because some pods require a SSL-certificated connection.
|
||||
|
||||
|
@ -130,14 +130,33 @@ RSS feed of the conversations at your site
|
|||
|
||||
https://helpers.pyxis.uberspace.de/dfrn_poll/helpers/converse
|
||||
|
||||
<a name="clients"></a>
|
||||
|
||||
**Are there any clients for friendica I can use?**
|
||||
|
||||
Friendica is using a [Twitter/StatusNet compatible API](help/api), which means you can use any Twitter/StatusNet/GNU Social client for your plattform as long as you can change the API path in its settings. Here is a list of known working clients
|
||||
|
||||
* Android
|
||||
* Friendica Client for Android
|
||||
* AndStatus
|
||||
* Twidere
|
||||
* Mustard and Mustard-Mod
|
||||
* Linux
|
||||
* Hotot
|
||||
* Choqok
|
||||
* MacOS X
|
||||
* Hotot
|
||||
* Windows
|
||||
* Hotot
|
||||
|
||||
Depending on the features of the client you might encounter some glitches in usability, like being limited in the length of your postings to 140 characters and having no access to the [permission settings](help/Groups-and-Privacy).
|
||||
|
||||
<a name="help"></a>
|
||||
|
||||
**Where I can find help?**
|
||||
|
||||
If you have problems with your Friendica page, you can ask the community at the [Friendica Support Group](https://helpers.pyxis.uberspace.de/profile/helpers). If you can't use your default profile you can either use a test account [test server](http://friendica.com/node/31) respectively an account at a public site [list](http://dir.friendica.com/siteinfo) or you can use the Librelist mailing list. If you want to use the mailing list, please just send a mail to friendica AT librelist DOT com.
|
||||
|
||||
If you are using Friendica Red, you will also find help at this forum: [Friendica Red Development](https://myfriendica.net/profile/friendicared).
|
||||
|
||||
If you are a theme developer, you will find help at this forum: [Friendica Theme Developers](https://friendica.eu/profile/ftdevs).
|
||||
|
||||
Admin
|
||||
|
@ -147,14 +166,14 @@ Admin
|
|||
|
||||
**Can I configure multiple domains with the same code instance?**
|
||||
|
||||
You can do that. What you can't do is point two different domains at the same database. As long as .htconfig.php exists to keep it from trying to do an install, you can keep the real config in include/$hostname/.htconfig.php All of the cache and lock stuff can be configured per instance.
|
||||
This function is not supported anymore starting from Friendica 3.3
|
||||
|
||||
<a name="sources"></a>
|
||||
|
||||
**Where can I find the source code of friendica, addons and themes?**
|
||||
|
||||
You can find the main respository [here](https://github.com/friendica/friendica). There you will always find the current stable version of friendica. The source files of Friendica Red are [here](https://github.com/friendica/red).
|
||||
You can find the main respository [here](https://github.com/friendica/friendica). There you will always find the current stable version of friendica.
|
||||
|
||||
Addons are listed at [this page](https://github.com/friendica/friendica-addons).
|
||||
|
||||
If you are searching for new themes, you can find them at [Friendica-Themes.com](http://friendica-themes.com/)
|
||||
If you are searching for new themes, you can find them at [Friendica-Themes.com](http://friendica-themes.com/)
|
||||
|
|
|
@ -33,6 +33,8 @@ Friendica Documentation and Resources
|
|||
* [Message Flow](help/Message-Flow)
|
||||
* [Using SSL with Friendica](help/SSL)
|
||||
* [Developers](help/Developers)
|
||||
* [Twitter/StatusNet API Functions](help/api)
|
||||
* [Translation of Friendica](help/translations)
|
||||
|
||||
|
||||
**External Resources**
|
||||
|
|
|
@ -70,19 +70,6 @@ This plugin reduces the database load massively. Downside: You can't see the tot
|
|||
|
||||
Go to the admin settings of "altpager" and set it to "global".
|
||||
|
||||
###Privacy Image Cache
|
||||
|
||||
**Description**
|
||||
|
||||
This plugin pre-fetches external content and stores it in the cache. Besides speeding up the page rendering it is also good for the privacy of your users, since embedded pictures are loaded from your site and not from a foreign site (that could spy on the IP addresses).
|
||||
|
||||
Additionally it helps with content from external sites that have slow performance or aren not online all the time.
|
||||
|
||||
**Administration**
|
||||
|
||||
Please create a folder named "privacy_image_cache" and "photo" in your web root. If these folders exists then the cached files will be stored there. This has the great advantage that your web server will fetch the files directly from there.
|
||||
|
||||
|
||||
###rendertime
|
||||
|
||||
This plugin doesn't speed up your system. It helps analyzing your bottlenecks.
|
||||
|
|
|
@ -5,9 +5,7 @@ Making Friends
|
|||
|
||||
Friendship in Friendica can take on a great many different meanings. But let's keep it simple, you want to be friends with somebody. How do you do it?
|
||||
|
||||
The easiest thing to do is to join the <a href="http://kakste.com/profile/newhere">New Here</a> group. This group is especially for people new to the Friendica network. Simply connect to the group, post to the wall, and make new friends. You don't even have to like us - comment on a few of our posts, and other people will start to add you too.
|
||||
|
||||
The next thing you can do is look at the Directory. The directory is split up into two parts. If you click the directory button, you will be presented with a list of all members (who chose to be listed) on your server. You'll also see a link to the Global Directory. If you click through to the global directory, you will be presented with a list of everybody who chose to be listed across all instances of Friendica. You will also see a "Show Community Forums" link, which will direct you to Groups, Forums and Fanpages. You connect to people, groups and forums in the same way, except groups and forums will automatically accept your introduction request, whereas a human will approve you manually.
|
||||
The first thing you can do is look at the Directory. The directory is split up into two parts. If you click the directory button, you will be presented with a list of all members (who chose to be listed) on your server. You'll also see a link to the Global Directory. If you click through to the global directory, you will be presented with a list of everybody who chose to be listed across all instances of Friendica. You will also see a "Show Community Forums" link, which will direct you to Groups, Forums and Fanpages. You connect to people, groups and forums in the same way, except groups and forums will automatically accept your introduction request, whereas a human will approve you manually.
|
||||
|
||||
To connect with other Friendica users:
|
||||
|
||||
|
|
|
@ -7,12 +7,8 @@ Here are some more things to help get you started:
|
|||
**Groups**
|
||||
|
||||
|
||||
- <a href="https://kakste.com/profile/newhere">New Here</a> - a group for people new to Friendica
|
||||
|
||||
- <a href="http://helpers.pyxis.uberspace.de/profile/helpers">Friendica Support</a> - problems? This is the place to ask.
|
||||
|
||||
- <a href="https://kakste.com/profile/public_stream">Public Stream</a> - a place to talk about anything to anyone.
|
||||
|
||||
- <a href="https://letstalk.pyxis.uberspace.de/profile/letstalk">Let's Talk</a> a group for finding people and groups who share similar interests.
|
||||
|
||||
- <a href="http://newzot.hydra.uberspace.de/profile/newzot">Local Friendica</a> a page for local Friendica groups</a>
|
||||
|
|
362
doc/api.md
Normal file
362
doc/api.md
Normal file
|
@ -0,0 +1,362 @@
|
|||
The friendica API aims to be compatible to the [StatusNet API](http://status.net/wiki/Twitter-compatible_API) which aims to be compatible to the [Twitter API 1.0](https://dev.twitter.com/docs/api/1).
|
||||
|
||||
Please refer to the linked documentation for further information.
|
||||
|
||||
## Implemented API calls
|
||||
|
||||
### General
|
||||
#### Unsupported parameters
|
||||
* cursor: Not implemented in StatusNet
|
||||
* trim_user: Not implemented in StatusNet
|
||||
* contributor_details: Not implemented in StatusNet
|
||||
* place_id: Not implemented in StatusNet
|
||||
* display_coordinates: Not implemented in StatusNet
|
||||
* include_rts: To-Do
|
||||
* include_my_retweet: Retweets in friendica are implemented in a different way
|
||||
|
||||
#### Different behaviour
|
||||
* screen_name: The nick name in friendica is only unique in each network but not for all networks. The users are searched in the following priority: Friendica, StatusNet/GNU Social, Diaspora, pump.io, Twitter. If no contact was found by this way, then the first contact is taken.
|
||||
* include_entities: Default is "false". If set to "true" then the plain text is formatted so that links are having descriptions.
|
||||
|
||||
#### Return values
|
||||
* cid: Contact id of the user (important for "contact_allow" and "contact_deny")
|
||||
* network: network of the user
|
||||
|
||||
### account/verify_credentials
|
||||
#### Parameters
|
||||
* skip_status: Don't show the "status" field. (Default: false)
|
||||
* include_entities: "true" shows entities for pictures and links (Default: false)
|
||||
|
||||
### statuses/update, statuses/update_with_media
|
||||
#### Parameters
|
||||
* title: Title of the status
|
||||
* status: Status in text format
|
||||
* htmlstatus: Status in HTML format
|
||||
* in_reply_to_status_id
|
||||
* lat: latitude
|
||||
* long: longitude
|
||||
* media: image data
|
||||
* source: Application name
|
||||
* group_allow
|
||||
* contact_allow
|
||||
* group_deny
|
||||
* contact_deny
|
||||
* network
|
||||
* include_entities: "true" shows entities for pictures and links (Default: false)
|
||||
|
||||
#### Unsupported parameters
|
||||
* trim_user
|
||||
* place_id
|
||||
* display_coordinates
|
||||
|
||||
### users/search
|
||||
#### Parameters
|
||||
* q: name of the user
|
||||
|
||||
#### Unsupported parameters
|
||||
* page
|
||||
* count
|
||||
* include_entities
|
||||
|
||||
### users/show
|
||||
#### Parameters
|
||||
* user_id: id of the user
|
||||
* screen_name: screen name (for technical reasons, this value is not unique!)
|
||||
* include_entities: "true" shows entities for pictures and links (Default: false)
|
||||
|
||||
### statuses/home_timeline
|
||||
#### Parameters
|
||||
* count: Items per page (default: 20)
|
||||
* page: page number
|
||||
* since_id: minimal id
|
||||
* max_id: maximum id
|
||||
* exclude_replies: don't show replies (default: false)
|
||||
* conversation_id: Shows all statuses of a given conversation.
|
||||
* include_entities: "true" shows entities for pictures and links (Default: false)
|
||||
|
||||
#### Unsupported parameters
|
||||
* include_rts
|
||||
* trim_user
|
||||
* contributor_details
|
||||
|
||||
### statuses/friends_timeline
|
||||
#### Parameters
|
||||
* count: Items per page (default: 20)
|
||||
* page: page number
|
||||
* since_id: minimal id
|
||||
* max_id: maximum id
|
||||
* exclude_replies: don't show replies (default: false)
|
||||
* conversation_id: Shows all statuses of a given conversation.
|
||||
* include_entities: "true" shows entities for pictures and links (Default: false)
|
||||
|
||||
#### Unsupported parameters
|
||||
* include_rts
|
||||
* trim_user
|
||||
* contributor_details
|
||||
|
||||
### statuses/public_timeline
|
||||
#### Parameters
|
||||
* count: Items per page (default: 20)
|
||||
* page: page number
|
||||
* since_id: minimal id
|
||||
* max_id: maximum id
|
||||
* exclude_replies: don't show replies (default: false)
|
||||
* conversation_id: Shows all statuses of a given conversation.
|
||||
* include_entities: "true" shows entities for pictures and links (Default: false)
|
||||
|
||||
#### Unsupported parameters
|
||||
* trim_user
|
||||
|
||||
### statuses/show
|
||||
#### Parameters
|
||||
* id: message number
|
||||
* conversation: if set to "1" show all messages of the conversation with the given id
|
||||
* include_entities: "true" shows entities for pictures and links (Default: false)
|
||||
|
||||
#### Unsupported parameters
|
||||
* include_my_retweet
|
||||
* trim_user
|
||||
|
||||
### statuses/retweet
|
||||
#### Parameters
|
||||
* id: message number
|
||||
* include_entities: "true" shows entities for pictures and links (Default: false)
|
||||
|
||||
#### Unsupported parameters
|
||||
* trim_user
|
||||
|
||||
### statuses/destroy
|
||||
#### Parameters
|
||||
* id: message number
|
||||
* include_entities: "true" shows entities for pictures and links (Default: false)
|
||||
|
||||
#### Unsupported parameters
|
||||
* trim_user
|
||||
|
||||
### statuses/mentions
|
||||
#### Parameters
|
||||
* count: Items per page (default: 20)
|
||||
* page: page number
|
||||
* since_id: minimal id
|
||||
* max_id: maximum id
|
||||
* include_entities: "true" shows entities for pictures and links (Default: false)
|
||||
|
||||
#### Unsupported parameters
|
||||
* include_rts
|
||||
* trim_user
|
||||
* contributor_details
|
||||
|
||||
### statuses/replies
|
||||
#### Parameters
|
||||
* count: Items per page (default: 20)
|
||||
* page: page number
|
||||
* since_id: minimal id
|
||||
* max_id: maximum id
|
||||
* include_entities: "true" shows entities for pictures and links (Default: false)
|
||||
|
||||
#### Unsupported parameters
|
||||
* include_rts
|
||||
* trim_user
|
||||
* contributor_details
|
||||
|
||||
### statuses/user_timeline
|
||||
#### Parameters
|
||||
* user_id: id of the user
|
||||
* screen_name: screen name (for technical reasons, this value is not unique!)
|
||||
* count: Items per page (default: 20)
|
||||
* page: page number
|
||||
* since_id: minimal id
|
||||
* max_id: maximum id
|
||||
* exclude_replies: don't show replies (default: false)
|
||||
* conversation_id: Shows all statuses of a given conversation.
|
||||
* include_entities: "true" shows entities for pictures and links (Default: false)
|
||||
|
||||
#### Unsupported parameters
|
||||
* include_rts
|
||||
* trim_user
|
||||
* contributor_details
|
||||
|
||||
### conversation/show
|
||||
Unofficial Twitter command. It shows all direct answers (excluding the original post) to a given id.
|
||||
|
||||
#### Parameters
|
||||
* id: id of the post
|
||||
* count: Items per page (default: 20)
|
||||
* page: page number
|
||||
* since_id: minimal id
|
||||
* max_id: maximum id
|
||||
* include_entities: "true" shows entities for pictures and links (Default: false)
|
||||
|
||||
#### Unsupported parameters
|
||||
* include_rts
|
||||
* trim_user
|
||||
* contributor_details
|
||||
|
||||
### favorites
|
||||
#### Parameters
|
||||
* count: Items per page (default: 20)
|
||||
* page: page number
|
||||
* since_id: minimal id
|
||||
* max_id: maximum id
|
||||
* include_entities: "true" shows entities for pictures and links (Default: false)
|
||||
|
||||
#### Unsupported parameters
|
||||
* user_id
|
||||
* screen_name
|
||||
|
||||
Favorites aren't displayed to other users, so "user_id" and "screen_name". So setting this value will result in an empty array.
|
||||
|
||||
### account/rate_limit_status
|
||||
|
||||
### help/test
|
||||
|
||||
### statuses/friends
|
||||
* include_entities: "true" shows entities for pictures and links (Default: false)
|
||||
|
||||
#### Unsupported parameters
|
||||
* user_id
|
||||
* screen_name
|
||||
* cursor
|
||||
|
||||
Friendica doesn't allow showing friends of other users.
|
||||
|
||||
### statuses/followers
|
||||
* include_entities: "true" shows entities for pictures and links (Default: false)
|
||||
|
||||
#### Unsupported parameters
|
||||
* user_id
|
||||
* screen_name
|
||||
* cursor
|
||||
|
||||
Friendica doesn't allow showing followers of other users.
|
||||
|
||||
### statusnet/config
|
||||
|
||||
### statusnet/version
|
||||
|
||||
### friends/ids
|
||||
#### Parameters
|
||||
* stringify_ids: Should the id numbers be sent as text (true) or number (false)? (default: false)
|
||||
|
||||
#### Unsupported parameters
|
||||
* user_id
|
||||
* screen_name
|
||||
* cursor
|
||||
|
||||
Friendica doesn't allow showing friends of other users.
|
||||
|
||||
### followers/ids
|
||||
#### Parameters
|
||||
* stringify_ids: Should the id numbers be sent as text (true) or number (false)? (default: false)
|
||||
|
||||
#### Unsupported parameters
|
||||
* user_id
|
||||
* screen_name
|
||||
* cursor
|
||||
|
||||
Friendica doesn't allow showing followers of other users.
|
||||
|
||||
### direct_messages/new
|
||||
#### Parameters
|
||||
* user_id: id of the user
|
||||
* screen_name: screen name (for technical reasons, this value is not unique!)
|
||||
* text: The message
|
||||
* replyto: ID of the replied direct message
|
||||
* title: Title of the direct message
|
||||
|
||||
### direct_messages/conversation
|
||||
Shows all direct messages of a conversation
|
||||
#### Parameters
|
||||
* count: Items per page (default: 20)
|
||||
* page: page number
|
||||
* since_id: minimal id
|
||||
* max_id: maximum id
|
||||
* getText: Defines the format of the status field. Can be "html" or "plain"
|
||||
* uri: URI of the conversation
|
||||
|
||||
### direct_messages/all
|
||||
#### Parameters
|
||||
* count: Items per page (default: 20)
|
||||
* page: page number
|
||||
* since_id: minimal id
|
||||
* max_id: maximum id
|
||||
* getText: Defines the format of the status field. Can be "html" or "plain"
|
||||
|
||||
### direct_messages/sent
|
||||
#### Parameters
|
||||
* count: Items per page (default: 20)
|
||||
* page: page number
|
||||
* since_id: minimal id
|
||||
* max_id: maximum id
|
||||
* getText: Defines the format of the status field. Can be "html" or "plain"
|
||||
* include_entities: "true" shows entities for pictures and links (Default: false)
|
||||
|
||||
### direct_messages
|
||||
#### Parameters
|
||||
* count: Items per page (default: 20)
|
||||
* page: page number
|
||||
* since_id: minimal id
|
||||
* max_id: maximum id
|
||||
* getText: Defines the format of the status field. Can be "html" or "plain"
|
||||
* include_entities: "true" shows entities for pictures and links (Default: false)
|
||||
|
||||
#### Unsupported parameters
|
||||
* skip_status
|
||||
|
||||
### oauth/request_token
|
||||
#### Parameters
|
||||
* oauth_callback
|
||||
|
||||
#### Unsupported parameters
|
||||
* x_auth_access_type
|
||||
|
||||
### oauth/access_token
|
||||
#### Parameters
|
||||
* oauth_verifier
|
||||
|
||||
#### Unsupported parameters
|
||||
* x_auth_password
|
||||
* x_auth_username
|
||||
* x_auth_mode
|
||||
|
||||
## Not Implemented API calls
|
||||
The following list is extracted from the [API source file](https://github.com/friendica/friendica/blob/master/include/api.php) (at the very bottom):
|
||||
* favorites/create
|
||||
* favorites/destroy
|
||||
* statuses/retweets_of_me
|
||||
* friendships/create
|
||||
* friendships/destroy
|
||||
* friendships/exists
|
||||
* friendships/show
|
||||
* account/update_location
|
||||
* account/update_profile_background_image
|
||||
* account/update_profile_image
|
||||
* blocks/create
|
||||
* blocks/destroy
|
||||
|
||||
The following are things from the Twitter API also not implemented in StatusNet:
|
||||
* statuses/retweeted_to_me
|
||||
* statuses/retweeted_by_me
|
||||
* direct_messages/destroy
|
||||
* account/end_session
|
||||
* account/update_delivery_device
|
||||
* notifications/follow
|
||||
* notifications/leave
|
||||
* blocks/exists
|
||||
* blocks/blocking
|
||||
* lists
|
||||
|
||||
## Usage Examples
|
||||
### BASH / cURL
|
||||
Betamax has documentated some example API usage from a [bash script](https://en.wikipedia.org/wiki/Bash_(Unix_shell) employing [curl](https://en.wikipedia.org/wiki/CURL) (see [his posting](https://betamax65.de/display/betamax65/43539)).
|
||||
|
||||
/usr/bin/curl -u USER:PASS https://YOUR.FRIENDICA.TLD/api/statuses/update.xml -d source="some source id" -d status="the status you want to post"
|
||||
|
||||
### Python
|
||||
The [RSStoFriedika](https://github.com/pafcu/RSStoFriendika) code can be used as an example of how to use the API with python. The lines for posting are located at [line 21](https://github.com/pafcu/RSStoFriendika/blob/master/RSStoFriendika.py#L21) and following.
|
||||
|
||||
def tweet(server, message, group_allow=None):
|
||||
url = server + '/api/statuses/update'
|
||||
urllib2.urlopen(url, urllib.urlencode({'status': message,'group_allow[]':group_allow}, doseq=True))
|
||||
|
||||
There is also a [module for python 3](https://bitbucket.org/tobiasd/python-friendica) for using the API.
|
|
@ -33,6 +33,8 @@ Friendica - Dokumentation und Ressourcen
|
|||
* [Nachrichtenfluss](help/Message-Flow)
|
||||
* [Betreibe deine Seite mit einem SSL-Zertifikat](help/SSL)
|
||||
* [Entwickler](help/Developers)
|
||||
* [Twitter/StatusNet API Functions](help/api) (EN)
|
||||
* [Translation of Friendica](help/translations) (EN)
|
||||
|
||||
|
||||
**Externe Ressourcen**
|
||||
|
|
|
@ -12,7 +12,7 @@ Wenn du Fragen zu den folgenden Anweisungen oder zu anderen Themen hast, dann ka
|
|||
Systemeinstellungen
|
||||
---------------
|
||||
|
||||
Geh auf /admin/site in deinem System und ändere die folgenden Werte:
|
||||
Geh auf /admin/site in deinem System und ändere die folgenden Werte:
|
||||
|
||||
setze "Qualität des JPEG Bildes" auf 50.
|
||||
|
||||
|
@ -36,20 +36,20 @@ Wenn du MyISAM (Standardeinstellung) nutzt, dann beschleunigt dies die Suche.
|
|||
|
||||
setze "Pfad zum Eintrag Cache" auf einen leeren Ordner außerhalb deines Stammverzeichnisses.
|
||||
|
||||
Verarbeiteter BBCode und einige externe Bilder werden hier gespeichert. BBCode verarbeiten ist ein zeitintensiver Prozess, der zudem eine hohe CPU-Leistung erfordert.
|
||||
Verarbeiteter BBCode und einige externe Bilder werden hier gespeichert. BBCode verarbeiten ist ein zeitintensiver Prozess, der zudem eine hohe CPU-Leistung erfordert.
|
||||
|
||||
Du kannst den gleichen Ordner nutzen, den du für die Sperrdatei genutzt hast.
|
||||
Du kannst den gleichen Ordner nutzen, den du für die Sperrdatei genutzt hast.
|
||||
|
||||
**Warnung!**
|
||||
|
||||
Der Ordner für den Eintrag-Cache wird regelmäßig geleert. Jede Datei, die die Cache-Dauer überschreitet, wird gelöscht. **Wenn du versehentlich den Cache-Pfad auf dein Stammverzeichnis legst, dann würde dir dies das gesamte Stammverzeichnis löschen.**
|
||||
Der Ordner für den Eintrag-Cache wird regelmäßig geleert. Jede Datei, die die Cache-Dauer überschreitet, wird gelöscht. **Wenn du versehentlich den Cache-Pfad auf dein Stammverzeichnis legst, dann würde dir dies das gesamte Stammverzeichnis löschen.**
|
||||
|
||||
Prüfe also doppelt, dass der gewählte Ordner nur temporäre Dateien enthält, die jederzeit gelöscht werden können.
|
||||
Prüfe also doppelt, dass der gewählte Ordner nur temporäre Dateien enthält, die jederzeit gelöscht werden können.
|
||||
|
||||
Plugins
|
||||
--------
|
||||
|
||||
Aktiviere die folgenden Plugins:
|
||||
Aktiviere die folgenden Plugins:
|
||||
|
||||
Alternate Pagination
|
||||
Privacy Image Cache
|
||||
|
@ -59,29 +59,17 @@ Aktiviere die folgenden Plugins:
|
|||
|
||||
**Beschreibung**
|
||||
|
||||
Dieses Plugin reduziert die Ladezeit der Datenbank massiv. Nachteil: Du kannst nicht mehr die Anzahl aller Seiten sehen.
|
||||
Dieses Plugin reduziert die Ladezeit der Datenbank massiv. Nachteil: Du kannst nicht mehr die Anzahl aller Seiten sehen.
|
||||
|
||||
**Einrichtung**
|
||||
|
||||
Gehe auf admin/plugins/altpager und wähle "global".
|
||||
|
||||
###Privacy Image Cache
|
||||
|
||||
**Beschreibung**
|
||||
|
||||
Dieses Plugin lädt externe Inhalte vor und speichert sie im Cache. Neben der Beschleunigung der Seite dient es so außerdem dazu, die Privatssphäre der Nutzer zu schützen, da eingebettete Inhalte so von deiner Seite aus geladen werden und nicht von externen Quellen (die deine IP-Adresse ermitteln könnten).
|
||||
|
||||
Ebenso hilft es bei Inhalten, die nur langsam laden oder nicht immer online sind.
|
||||
|
||||
**Einrichtung**
|
||||
|
||||
Bitte erstelle einen Ordner namens "privacy_image_cache" und "photo" in deinem Stammverzeichnis. Wenn diese Ordner existieren, dann werden die zwischengespeicherten Inhalte dort abgelegt. Dies hat den großen Vorteil, dass der Server die Dateien direkt von dort bezieht.
|
||||
|
||||
###rendertime
|
||||
|
||||
**Beschreibung**
|
||||
|
||||
Dieses Plugin beschleunigt dein System nicht, aber es hilft dabei, die Flaschenhälse zu ermitteln.
|
||||
Dieses Plugin beschleunigt dein System nicht, aber es hilft dabei, die Flaschenhälse zu ermitteln.
|
||||
|
||||
Wenn es aktiviert ist, dann siehst du Werte wie die folgenden auf jeder deiner Seiten:
|
||||
|
||||
|
@ -100,17 +88,17 @@ Diese Werte zeigen deine Performance-Probleme.
|
|||
Webserver
|
||||
----------
|
||||
|
||||
Wenn du einen Apache-Webserver nutzt, aktiviere bitte die folgenden Module:
|
||||
Wenn du einen Apache-Webserver nutzt, aktiviere bitte die folgenden Module:
|
||||
|
||||
###Cache-Control
|
||||
|
||||
**Beschreibung**
|
||||
|
||||
Dieses Modul weist den Client an, den Inhalt statischer Dateien zu speichern, um diese nicht immer wieder neu laden zu müssen.
|
||||
Dieses Modul weist den Client an, den Inhalt statischer Dateien zu speichern, um diese nicht immer wieder neu laden zu müssen.
|
||||
|
||||
Aktiviere das Modul "mod_expires", indem du "a2enmod expires" als root eingibst.
|
||||
|
||||
Füge die folgenden Zeilen in die Apache-Konfiguration deiner Seite im "directory"-Bereich ein.
|
||||
Füge die folgenden Zeilen in die Apache-Konfiguration deiner Seite im "directory"-Bereich ein.
|
||||
|
||||
ExpiresActive on ExpiresDefault "access plus 1 week"
|
||||
|
||||
|
@ -120,7 +108,7 @@ Weitere Informationen findest du hier: http://httpd.apache.org/docs/2.2/mod/mod_
|
|||
|
||||
**Beschreibung**
|
||||
|
||||
Dieses Modul komprimiert den Datenverkehr (Traffic) zwischen dem Webserver und dem Client.
|
||||
Dieses Modul komprimiert den Datenverkehr (Traffic) zwischen dem Webserver und dem Client.
|
||||
|
||||
Aktiviere das Modul "mod_deflate" durch die Eingabe "a2enmod deflate" als root.
|
||||
|
||||
|
@ -131,7 +119,7 @@ Weitere Informationen findest du hier: http://httpd.apache.org/docs/2.2/mod/mod_
|
|||
|
||||
**FCGI**
|
||||
|
||||
Wenn du Apache nutzt, dann denk darüber nach, FCGI zu nutzen. Wenn du eine Debian-basierte Distribution nutzt, dann wirst du die Pakete "php5-cgi" und "libapache2-mod-fcgid" benötigen.
|
||||
Wenn du Apache nutzt, dann denk darüber nach, FCGI zu nutzen. Wenn du eine Debian-basierte Distribution nutzt, dann wirst du die Pakete "php5-cgi" und "libapache2-mod-fcgid" benötigen.
|
||||
Nutze externe Dokumente, um eine detailiertere Erklärung für die Einrichtung eines Systems auf FCGI-Basis zu erhalten.
|
||||
|
||||
**APC**
|
||||
|
@ -142,6 +130,6 @@ Wenn APC aktiviert ist, dann nutzt Friendica dies, um Konfigurationseinstellunge
|
|||
|
||||
###Database
|
||||
|
||||
Es gibt Skripte wie [tuning-primer.sh](http://www.day32.com/MySQL/) und [mysqltuner.pl](http://mysqltuner.pl), die den Datenbankserver analysieren und Hinweise darauf geben, welche Werte verändert werden könnten.
|
||||
|
||||
Aktivere hierfür die "Slow query" Log-Datei, um Performanceprobleme zu erkennen.
|
||||
Es gibt Skripte wie [tuning-primer.sh](http://www.day32.com/MySQL/) und [mysqltuner.pl](http://mysqltuner.pl), die den Datenbankserver analysieren und Hinweise darauf geben, welche Werte verändert werden könnten.
|
||||
|
||||
Aktivere hierfür die "Slow query" Log-Datei, um Performanceprobleme zu erkennen.
|
||||
|
|
|
@ -8,12 +8,8 @@ Hier sind noch einige weitere Dinge, die dir den Start vereinfachen können.
|
|||
**Gruppen**
|
||||
|
||||
|
||||
- <a href="https://kakste.com/profile/newhere">Neu hier?</a> - eine Gruppe für Leute, die neu bei Friendica sind
|
||||
|
||||
- <a href="http://helpers.pyxis.uberspace.de/profile/helpers">Friendica Support</a> - Probleme? Dann ist das der Platz, um zu fragen!
|
||||
|
||||
- <a href="https://kakste.com/profile/public_stream">Öffentlicher Stream</a> - ein Platz, um über alles mit jedem zu reden.
|
||||
|
||||
- <a href="https://letstalk.pyxis.uberspace.de/profile/letstalk">Let's Talk</a> eine Gruppe, um Leute und Gruppen mit gleichen Interessen zu finden
|
||||
|
||||
- <a href="http://newzot.hydra.uberspace.de/profile/newzot">Local Friendica</a> eine Seite für lokale Friendica-Gruppen</a>
|
||||
|
|
48
doc/readme.md
Normal file
48
doc/readme.md
Normal file
|
@ -0,0 +1,48 @@
|
|||
Friendica Documentation and Resources
|
||||
=====================================
|
||||
|
||||
**Contents**
|
||||
|
||||
* General functions - first steps
|
||||
* [Account Basics](help/Account-Basics)
|
||||
* [New User Quick Start](help/Quick-Start-guide)
|
||||
* [Creating posts](help/Text_editor)
|
||||
* [BBCode tag reference](help/BBCode)
|
||||
* [Comment, sort and delete posts](help/Text_comment)
|
||||
* [Profiles](help/Profiles)
|
||||
* You and other user
|
||||
* [Connectors](help/Connectors)
|
||||
* [Making Friends](help/Making-Friends)
|
||||
* [Groups and Privacy](help/Groups-and-Privacy)
|
||||
* [Tags and Mentions](help/Tags-and-Mentions)
|
||||
* [Community Forums](help/Forums)
|
||||
* [Chats](help/Chats)
|
||||
* Further information
|
||||
* [Improve Performance](help/Improve-Performance)
|
||||
* [Move Account](help/Move-Account)
|
||||
* [Remove Account](help/Remove-Account)
|
||||
* [Bugs and Issues](help/Bugs-and-Issues)
|
||||
* [Frequently asked questions (FAQ)](help/FAQ)
|
||||
|
||||
**Technical Documentation**
|
||||
|
||||
* [Install](help/Install)
|
||||
* [Settings](help/Settings)
|
||||
* [Plugins](help/Plugins)
|
||||
* [Installing Connectors (Facebook/Twitter/StatusNet)](help/Installing-Connectors)
|
||||
* [Message Flow](help/Message-Flow)
|
||||
* [Using SSL with Friendica](help/SSL)
|
||||
* [Developers](help/Developers)
|
||||
* [Twitter/StatusNet API Functions](help/api)
|
||||
* [Translation of Friendica](help/translations)
|
||||
|
||||
|
||||
**External Resources**
|
||||
|
||||
* [Main Website](http://friendica.com)
|
||||
* [Mailing List Archive](http://librelist.com/browser/friendica/)
|
||||
|
||||
**About**
|
||||
|
||||
* [Site/Version Info](friendica)
|
||||
|
95
doc/translations.md
Normal file
95
doc/translations.md
Normal file
|
@ -0,0 +1,95 @@
|
|||
Friendica translations
|
||||
======================
|
||||
|
||||
Translation Process
|
||||
-------------------
|
||||
|
||||
The strings used in the UI of Friendica is translated at [Transifex] [1] and then
|
||||
included in the git repository at github. If you want to help with translation
|
||||
for any language, be it correcting terms or translating friendica to a
|
||||
currently not supported language, please register an account at transifex.com
|
||||
and contact the friendica translation team there.
|
||||
|
||||
Translating friendica is simple. Just use the online tool at transifex. If you
|
||||
don't want to deal with git & co. that is fine, we check the status of the
|
||||
translations regularly and import them into the source tree at github so that
|
||||
others can use them.
|
||||
|
||||
We do not include every translation from transifex in the source tree to avoid
|
||||
a scattered and disturbed overall experience. As an uneducated guess we have a
|
||||
lower limit of 50% translated strings before we include the language (for the
|
||||
core message.po file, addont translation will be included once all strings of
|
||||
an addon are translated. This limit is judging only by the amount of translated
|
||||
strings under the assumption that the most prominent strings for the UI will be
|
||||
translated first by a translation team. If you feel your translation useable
|
||||
before this limit, please contact us and we will probably include your teams
|
||||
work in the source tree.
|
||||
|
||||
If you want to get your work into the source tree yourself, feel free to do so
|
||||
and contact us with and question that arises. The process is simple and
|
||||
friendica ships with all the tools necessary.
|
||||
|
||||
The location of the translated files in the source tree is
|
||||
/view/LNG-CODE/
|
||||
where LNG-CODE is the language code used, e.g. de for German or fr for French.
|
||||
For the email templates (the *.tpl files) just place them into the directory
|
||||
and you are done. The translated strings come as a "message.po" file from
|
||||
transifex which needs to be translated into the PHP file friendica uses. To do
|
||||
so, place the file in the directory mentioned above and use the "po2php"
|
||||
utility from the util directory of your friendica installation.
|
||||
|
||||
Assuming you want to convert the German localization which is placed in
|
||||
view/de/message.po you would do the following.
|
||||
|
||||
1. Navigate at the command prompt to the base directory of your
|
||||
friendica installation
|
||||
|
||||
2. Execute the po2php script, which will place the translation
|
||||
in the strings.php file that is used by friendica.
|
||||
|
||||
$> php util/po2php.php view/de/message.po
|
||||
|
||||
The output of the script will be placed at view/de/strings.php where
|
||||
froemdoca os expecting it, so you can test your translation mmediately.
|
||||
|
||||
3. Visit your friendica page to check if it still works in the language you
|
||||
just translated. If not try to find the error, most likely PHP will give
|
||||
you a hint in the log/warnings.about the error.
|
||||
|
||||
For debugging you can also try to "run" the file with PHP. This should
|
||||
not give any output if the file is ok but might give a hint for
|
||||
searching the bug in the file.
|
||||
|
||||
$> php view/de/strings.php
|
||||
|
||||
4. commit the two files with a meaningful commit message to your git
|
||||
repository, push it to your fork of the friendica repository at github and
|
||||
issue a pull request for that commit.
|
||||
|
||||
Utilities
|
||||
---------
|
||||
|
||||
Additional to the po2php script there are some more utilities for translation
|
||||
in the "util" directory of the friendica source tree. If you only want to
|
||||
translate friendica into another language you wont need any of these tools most
|
||||
likely but it gives you an idea how the translation process of friendica
|
||||
works.
|
||||
|
||||
For further information see the utils/README file.
|
||||
|
||||
Known Problems
|
||||
--------------
|
||||
|
||||
Friendica uses the language setting of the visitors browser to determain the
|
||||
language for the UI. Most of the time this works, but there are some known
|
||||
quirks.
|
||||
|
||||
One is that some browsers, like Safari, do the setting to "de-de" but friendica
|
||||
only has a "de" localisation. A workaround would be to add a symbolic link
|
||||
from
|
||||
$friendica/view/de-de
|
||||
pointing to
|
||||
$friendica/view/de
|
||||
|
||||
[1]: https://www.transifex.com/projects/p/friendica/
|
||||
|
|
@ -59,7 +59,7 @@ $a->config['system']['directory_search_url'] = 'http://dir.friendica.com/directo
|
|||
|
||||
// PuSH - aka pubsubhubbub URL. This makes delivery of public posts as fast as private posts
|
||||
|
||||
$a->config['system']['huburl'] = 'http://pubsubhubbub.appspot.com';
|
||||
$a->config['system']['huburl'] = '[internal]';
|
||||
|
||||
// Server-to-server private message encryption (RINO) is allowed by default.
|
||||
// Encryption will only be provided if this setting is true and the
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 5.8 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 2.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 3 KiB |
|
@ -2,7 +2,7 @@
|
|||
|
||||
require_once('include/email.php');
|
||||
|
||||
class EmailNotification {
|
||||
class Emailer {
|
||||
/**
|
||||
* Send a multipart/alternative message with Text and HTML versions
|
||||
*
|
||||
|
@ -13,13 +13,13 @@ class EmailNotification {
|
|||
* @param messageSubject subject of the message
|
||||
* @param htmlVersion html version of the message
|
||||
* @param textVersion text only version of the message
|
||||
* @param additionalMailHeader additions to the smtp mail header
|
||||
*/
|
||||
static public function sendTextHtmlEmail($fromName,$fromEmail,$replyTo,$toEmail,$messageSubject,$htmlVersion,$textVersion) {
|
||||
static public function send($params) {
|
||||
|
||||
$fromName = email_header_encode(html_entity_decode($params['fromName'],ENT_QUOTES,'UTF-8'),'UTF-8');
|
||||
$messageSubject = email_header_encode(html_entity_decode($params['messageSubject'],ENT_QUOTES,'UTF-8'),'UTF-8');
|
||||
|
||||
$fromName = email_header_encode($fromName,'UTF-8');
|
||||
$messageSubject = email_header_encode($messageSubject,'UTF-8');
|
||||
|
||||
|
||||
// generate a mime boundary
|
||||
$mimeBoundary =rand(0,9)."-"
|
||||
.rand(10000000000,9999999999)."-"
|
||||
|
@ -28,14 +28,15 @@ class EmailNotification {
|
|||
|
||||
// generate a multipart/alternative message header
|
||||
$messageHeader =
|
||||
"From: {$fromName} <{$fromEmail}>\n" .
|
||||
"Reply-To: {$replyTo}\n" .
|
||||
$params['additionalMailHeader'] .
|
||||
"From: $fromName <{$params['fromEmail']}>\n" .
|
||||
"Reply-To: $fromName <{$params['replyTo']}>\n" .
|
||||
"MIME-Version: 1.0\n" .
|
||||
"Content-Type: multipart/alternative; boundary=\"{$mimeBoundary}\"";
|
||||
|
||||
// assemble the final multipart message body with the text and html types included
|
||||
$textBody = chunk_split(base64_encode($textVersion));
|
||||
$htmlBody = chunk_split(base64_encode($htmlVersion));
|
||||
$textBody = chunk_split(base64_encode($params['textVersion']));
|
||||
$htmlBody = chunk_split(base64_encode($params['htmlVersion']));
|
||||
$multipartMessageBody =
|
||||
"--" . $mimeBoundary . "\n" . // plain text section
|
||||
"Content-Type: text/plain; charset=UTF-8\n" .
|
||||
|
@ -49,12 +50,14 @@ class EmailNotification {
|
|||
|
||||
// send the message
|
||||
$res = mail(
|
||||
$toEmail, // send to address
|
||||
$params['toEmail'], // send to address
|
||||
$messageSubject, // subject
|
||||
$multipartMessageBody, // message body
|
||||
$messageHeader // message headers
|
||||
);
|
||||
logger("sendTextHtmlEmail: END");
|
||||
logger("header " . 'To: ' . $params['toEmail'] . "\n" . $messageHeader, LOGGER_DEBUG);
|
||||
logger("return value " . (($res)?"true":"false"), LOGGER_DEBUG);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
119
include/api.php
119
include/api.php
|
@ -26,6 +26,19 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
function api_source() {
|
||||
if (requestdata('source'))
|
||||
return (requestdata('source'));
|
||||
|
||||
// Support for known clients that doesn't send a source name
|
||||
if (strstr($_SERVER['HTTP_USER_AGENT'], "Twidere"))
|
||||
return ("Twidere");
|
||||
|
||||
logger("Unrecognized user-agent ".$_SERVER['HTTP_USER_AGENT'], LOGGER_DEBUG);
|
||||
|
||||
return ("api");
|
||||
}
|
||||
|
||||
function api_date($str){
|
||||
//Wed May 23 06:01:13 +0000 2007
|
||||
return datetime_convert('UTC', 'UTC', $str, "D M d H:i:s +0000 Y" );
|
||||
|
@ -122,7 +135,6 @@
|
|||
|
||||
// preset
|
||||
$type="json";
|
||||
|
||||
foreach ($API as $p=>$info){
|
||||
if (strpos($a->query_string, $p)===0){
|
||||
$called_api= explode("/",$p);
|
||||
|
@ -154,7 +166,10 @@
|
|||
case "json":
|
||||
header ("Content-Type: application/json");
|
||||
foreach($r as $rr)
|
||||
return json_encode($rr);
|
||||
$json = json_encode($rr);
|
||||
if ($_GET['callback'])
|
||||
$json = $_GET['callback']."(".$json.")";
|
||||
return $json;
|
||||
break;
|
||||
case "rss":
|
||||
header ("Content-Type: application/rss+xml");
|
||||
|
@ -710,8 +725,6 @@
|
|||
if($parent)
|
||||
$_REQUEST['type'] = 'net-comment';
|
||||
else {
|
||||
// logger("api_statuses_update: upload ".print_r($_FILES, true)." ".print_r($_POST, true)." ".print_r($_GET, true), LOGGER_DEBUG);
|
||||
//die("blubb");
|
||||
$_REQUEST['type'] = 'wall';
|
||||
if(x($_FILES,'media')) {
|
||||
// upload the image if we have one
|
||||
|
@ -727,6 +740,9 @@
|
|||
|
||||
$_REQUEST['api_source'] = true;
|
||||
|
||||
if (!x($_REQUEST, "source"))
|
||||
$_REQUEST["source"] = api_source();
|
||||
|
||||
// call out normal post function
|
||||
|
||||
require_once('mod/item.php');
|
||||
|
@ -936,6 +952,35 @@
|
|||
}
|
||||
api_register_func('api/users/show','api_users_show');
|
||||
|
||||
|
||||
function api_users_search(&$a, $type) {
|
||||
$page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
|
||||
|
||||
$userlist = array();
|
||||
|
||||
if (isset($_GET["q"])) {
|
||||
$r = q("SELECT id FROM unique_contacts WHERE name='%s'", dbesc($_GET["q"]));
|
||||
if (!count($r))
|
||||
$r = q("SELECT id FROM unique_contacts WHERE nick='%s'", dbesc($_GET["q"]));
|
||||
|
||||
if (count($r)) {
|
||||
foreach ($r AS $user) {
|
||||
$user_info = api_get_user($a, $user["id"]);
|
||||
//echo print_r($user_info, true)."\n";
|
||||
$userdata = api_apply_template("user", $type, array('user' => $user_info));
|
||||
$userlist[] = $userdata["user"];
|
||||
}
|
||||
$userlist = array("users" => $userlist);
|
||||
} else
|
||||
die(api_error($a, $type, t("User not found.")));
|
||||
} else
|
||||
die(api_error($a, $type, t("User not found.")));
|
||||
|
||||
return ($userlist);
|
||||
}
|
||||
|
||||
api_register_func('api/users/search','api_users_search');
|
||||
|
||||
/**
|
||||
*
|
||||
* http://developer.twitter.com/doc/get/statuses/home_timeline
|
||||
|
@ -1272,6 +1317,9 @@
|
|||
$_REQUEST['type'] = 'wall';
|
||||
$_REQUEST['api_source'] = true;
|
||||
|
||||
if (!x($_REQUEST, "source"))
|
||||
$_REQUEST["source"] = api_source();
|
||||
|
||||
require_once('mod/item.php');
|
||||
item_post($a);
|
||||
}
|
||||
|
@ -1359,7 +1407,7 @@
|
|||
AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
|
||||
AND `contact`.`id` = `item`.`contact-id`
|
||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
AND `item`.`parent` IN (SELECT `iid` from thread where uid = %d AND `mention`)
|
||||
AND `item`.`parent` IN (SELECT `iid` from thread where uid = %d AND `mention` AND !`ignored`)
|
||||
$sql_extra
|
||||
AND `item`.`id`>%d
|
||||
ORDER BY `item`.`id` DESC LIMIT %d ,%d ",
|
||||
|
@ -1790,7 +1838,17 @@
|
|||
|
||||
return($entities);
|
||||
}
|
||||
|
||||
function api_format_items_embeded_images($item, $text){
|
||||
$a = get_app();
|
||||
$text = preg_replace_callback(
|
||||
"|data:image/([^;]+)[^=]+=*|m",
|
||||
function($match) use ($a, $item) {
|
||||
return $a->get_baseurl()."/display/".$item['guid'];
|
||||
},
|
||||
$text);
|
||||
return $text;
|
||||
}
|
||||
|
||||
function api_format_items($r,$user_info, $filter_user = false) {
|
||||
|
||||
$a = get_app();
|
||||
|
@ -1848,17 +1906,23 @@
|
|||
//$statusbody = trim(html2plain(bbcode(api_clean_plain_items($item['body']), false, false, 5, true), 0));
|
||||
$html = bbcode(api_clean_plain_items($item['body']), false, false, 2, true);
|
||||
$statusbody = trim(html2plain($html, 0));
|
||||
|
||||
|
||||
// handle data: images
|
||||
$statusbody = api_format_items_embeded_images($item,$statusbody);
|
||||
|
||||
$statustitle = trim($item['title']);
|
||||
|
||||
if (($statustitle != '') and (strpos($statusbody, $statustitle) !== false))
|
||||
$statustext = trim($statusbody);
|
||||
else
|
||||
$statustext = trim($statustitle."\n\n".$statusbody);
|
||||
|
||||
|
||||
if (($item["network"] == NETWORK_FEED) and (strlen($statustext)> 1000))
|
||||
$statustext = substr($statustext, 0, 1000)."... \n".$item["plink"];
|
||||
|
||||
$statushtml = trim(bbcode($item['body'], false, false));
|
||||
|
||||
|
||||
$status = array(
|
||||
'text' => $statustext,
|
||||
'truncated' => False,
|
||||
|
@ -1876,7 +1940,7 @@
|
|||
//'attachments' => array(),
|
||||
'user' => $status_user ,
|
||||
//'entities' => NULL,
|
||||
'statusnet_html' => trim(bbcode($item['body'], false, false)),
|
||||
'statusnet_html' => $statushtml,
|
||||
'statusnet_conversation_id' => $item['parent'],
|
||||
);
|
||||
|
||||
|
@ -2198,13 +2262,6 @@
|
|||
function api_direct_messages_box(&$a, $type, $box) {
|
||||
if (api_user()===false) return false;
|
||||
|
||||
unset($_REQUEST["user_id"]);
|
||||
unset($_GET["user_id"]);
|
||||
|
||||
unset($_REQUEST["screen_name"]);
|
||||
unset($_GET["screen_name"]);
|
||||
|
||||
$user_info = api_get_user($a);
|
||||
|
||||
// params
|
||||
$count = (x($_GET,'count')?$_GET['count']:20);
|
||||
|
@ -2214,11 +2271,25 @@
|
|||
$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
|
||||
$max_id = (x($_REQUEST,'max_id')?$_REQUEST['max_id']:0);
|
||||
|
||||
$start = $page*$count;
|
||||
$user_id = (x($_REQUEST,'user_id')?$_REQUEST['user_id']:"");
|
||||
$screen_name = (x($_REQUEST,'screen_name')?$_REQUEST['screen_name']:"");
|
||||
|
||||
// caller user info
|
||||
unset($_REQUEST["user_id"]);
|
||||
unset($_GET["user_id"]);
|
||||
|
||||
unset($_REQUEST["screen_name"]);
|
||||
unset($_GET["screen_name"]);
|
||||
|
||||
$user_info = api_get_user($a);
|
||||
//$profile_url = $a->get_baseurl() . '/profile/' . $a->user['nickname'];
|
||||
$profile_url = $user_info["url"];
|
||||
|
||||
|
||||
// pagination
|
||||
$start = $page*$count;
|
||||
|
||||
// filters
|
||||
if ($box=="sentbox") {
|
||||
$sql_extra = "`mail`.`from-url`='".dbesc( $profile_url )."'";
|
||||
}
|
||||
|
@ -2235,11 +2306,19 @@
|
|||
if ($max_id > 0)
|
||||
$sql_extra .= ' AND `mail`.`id` <= '.intval($max_id);
|
||||
|
||||
if ($user_id !="") {
|
||||
$sql_extra .= ' AND `mail`.`contact-id` = ' . intval($user_id);
|
||||
}
|
||||
elseif($screen_name !=""){
|
||||
$sql_extra .= " AND `contact`.`nick` = '" . dbesc($screen_name). "'";
|
||||
}
|
||||
|
||||
$r = q("SELECT `mail`.*, `contact`.`nurl` AS `contact-url` FROM `mail`,`contact` WHERE `mail`.`contact-id` = `contact`.`id` AND `mail`.`uid`=%d AND $sql_extra AND `mail`.`id` > %d ORDER BY `mail`.`id` DESC LIMIT %d,%d",
|
||||
intval(api_user()),
|
||||
intval($since_id),
|
||||
intval($start), intval($count)
|
||||
);
|
||||
|
||||
|
||||
$ret = Array();
|
||||
foreach($r as $item) {
|
||||
|
@ -2247,12 +2326,11 @@
|
|||
$recipient = $user_info;
|
||||
$sender = api_get_user($a,normalise_link($item['contact-url']));
|
||||
}
|
||||
elseif ($box == "sentbox" || $item['from-url'] != $profile_url){
|
||||
elseif ($box == "sentbox" || $item['from-url'] == $profile_url){
|
||||
$recipient = api_get_user($a,normalise_link($item['contact-url']));
|
||||
$sender = $user_info;
|
||||
|
||||
}
|
||||
|
||||
$ret[]=api_format_messages($item, $recipient, $sender);
|
||||
}
|
||||
|
||||
|
@ -2350,9 +2428,6 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function api_share_as_retweet($a, $uid, &$item) {
|
||||
$body = trim($item["body"]);
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
|
|||
}
|
||||
|
||||
if ($plaintext)
|
||||
$text = sprintf('<a href="%s" target="_blank">%s</a>', $url, $title);
|
||||
$text = sprintf('<a href="%s" target="_blank">%s</a><br>', $url, $title);
|
||||
else {
|
||||
$text = sprintf('<span class="type-%s">', $type);
|
||||
|
||||
|
@ -92,35 +92,6 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
|
|||
return($Text);
|
||||
}
|
||||
|
||||
/* function bb_rearrange_link($shared) {
|
||||
if ($shared[1] != "type-link")
|
||||
return($shared[0]);
|
||||
|
||||
$newshare = trim($shared[2]);
|
||||
$newshare = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $newshare);
|
||||
|
||||
if (!strpos($shared[0], "[bookmark"))
|
||||
$newshare = preg_replace("/\[url\=(.*?)\](.*?)\[\/url\]/ism", '[bookmark=$1]$2[/bookmark]', $newshare, 1);
|
||||
|
||||
preg_match("/\[img\](.*?)\[\/img\]/ism", $newshare, $matches);
|
||||
|
||||
if ($matches) {
|
||||
$newshare = str_replace($matches[0], '', $newshare);
|
||||
$newshare = "[img]".$matches[1]."[/img]\n".$newshare;
|
||||
}
|
||||
|
||||
$search = array("\n\n", "\n ", " \n");
|
||||
$replace = array("\n", "\n", "\n");
|
||||
do {
|
||||
$oldtext = $newshare;
|
||||
$newshare = str_replace($search, $replace, $newshare);
|
||||
} while ($oldtext != $newshare);
|
||||
|
||||
$newshare = "[class=type-link]".$newshare."[/class]";
|
||||
|
||||
return($newshare);
|
||||
} */
|
||||
|
||||
function bb_rearrange_share($shared) {
|
||||
if (!in_array(strtolower($shared[2]), array("type-link", "type-audio", "type-video")))
|
||||
return($shared[0]);
|
||||
|
@ -211,7 +182,8 @@ function bb_cleanup_share($shared, $plaintext, $nolink) {
|
|||
if (isset($bookmark[1][0]))
|
||||
$link = $bookmark[1][0];
|
||||
|
||||
if (($title != "") AND (strpos($shared[1],$title) !== false))
|
||||
if (($title != "") AND ((strpos($shared[1],$title) !== false) OR
|
||||
(similar_text($shared[1],$title) / strlen($title)) > 0.9))
|
||||
$title = "";
|
||||
|
||||
// if (strpos($shared[1],$link) !== false)
|
||||
|
@ -534,10 +506,14 @@ function bb_ShareAttributes($share, $simplehtml) {
|
|||
if ($text != "")
|
||||
$text .= "<hr />";
|
||||
|
||||
$text .= $headline.'<blockquote class="shared_content">'.trim($share[3])."</blockquote><br />";
|
||||
if (substr(normalise_link($link), 0, 19) != "http://twitter.com/") {
|
||||
$text .= $headline.'<blockquote class="shared_content">'.trim($share[3])."</blockquote><br />";
|
||||
|
||||
if ($link != "")
|
||||
$text .= '<br /><a href="'.$link.'">[l]</a>';
|
||||
} else
|
||||
$text .= '<br /><a href="'.$link.'">'.$link.'</a>';
|
||||
|
||||
if ($link != "")
|
||||
$text .= '<br /><a href="'.$link.'">[l]</a>';
|
||||
break;
|
||||
case 4:
|
||||
$headline = '<div class="shared_header">';
|
||||
|
@ -674,10 +650,12 @@ function bb_RemovePictureLinks($match) {
|
|||
$text = Cache::get($match[1]);
|
||||
|
||||
if(is_null($text)){
|
||||
$a = get_app();
|
||||
|
||||
$ch = @curl_init($match[1]);
|
||||
@curl_setopt($ch, CURLOPT_NOBODY, true);
|
||||
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
@curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION."-".DB_UPDATE_VERSION.")");
|
||||
@curl_setopt($ch, CURLOPT_USERAGENT, $a->get_useragent());
|
||||
@curl_exec($ch);
|
||||
$curl_info = @curl_getinfo($ch);
|
||||
|
||||
|
@ -722,10 +700,12 @@ function bb_CleanPictureLinksSub($match) {
|
|||
$text = Cache::get($match[1]);
|
||||
|
||||
if(is_null($text)){
|
||||
$a = get_app();
|
||||
|
||||
$ch = @curl_init($match[1]);
|
||||
@curl_setopt($ch, CURLOPT_NOBODY, true);
|
||||
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
@curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION."-".DB_UPDATE_VERSION.")");
|
||||
@curl_setopt($ch, CURLOPT_USERAGENT, $a->get_useragent());
|
||||
@curl_exec($ch);
|
||||
$curl_info = @curl_getinfo($ch);
|
||||
|
||||
|
@ -817,13 +797,6 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
|||
// Rearrange shares to attachments
|
||||
$Text = preg_replace_callback("((.*?)\[class=(.*?)\](.*?)\[\/class\])ism", "bb_rearrange_share",$Text);
|
||||
|
||||
// Handle attached links or videos
|
||||
$Text = bb_attachment($Text, ($simplehtml != 4) AND ($simplehtml != 0), $tryoembed);
|
||||
|
||||
// Rearrange shared links
|
||||
// if (get_config("system", "rearrange_shared_links") AND (!$simplehtml OR $tryoembed))
|
||||
// $Text = preg_replace_callback("(\[class=(.*?)\](.*?)\[\/class\])ism","bb_rearrange_link",$Text);
|
||||
|
||||
// when the content is meant exporting to other systems then remove the avatar picture since this doesn't really look good on these systems
|
||||
if (!$tryoembed)
|
||||
$Text = preg_replace("/\[share(.*?)avatar\s?=\s?'.*?'\s?(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","\n[share$1$2]$3[/share]",$Text);
|
||||
|
@ -840,21 +813,22 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
|||
|
||||
// removing multiplicated newlines
|
||||
if (get_config("system", "remove_multiplicated_lines")) {
|
||||
$search = array("\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]", "[/li]\n", "\n[li]", "\n[ul]", "[/ul]\n", "\n\n[share ");
|
||||
$replace = array("\n\n", "\n", "\n", "[/quote]\n", "[/quote]", "[/li]", "[li]", "[ul]", "[/ul]", "\n[share ");
|
||||
$search = array("\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]", "[/li]\n", "\n[li]", "\n[ul]", "[/ul]\n", "\n\n[share ", "[/attachment]\n");
|
||||
$replace = array("\n\n", "\n", "\n", "[/quote]\n", "[/quote]", "[/li]", "[li]", "[ul]", "[/ul]", "\n[share ", "[/attachment]");
|
||||
do {
|
||||
$oldtext = $Text;
|
||||
$Text = str_replace($search, $replace, $Text);
|
||||
} while ($oldtext != $Text);
|
||||
}
|
||||
|
||||
// Handle attached links or videos
|
||||
$Text = bb_attachment($Text, ($simplehtml != 4) AND ($simplehtml != 0), $tryoembed);
|
||||
|
||||
$Text = str_replace(array("\r","\n"), array('<br />','<br />'), $Text);
|
||||
|
||||
if($preserve_nl)
|
||||
$Text = str_replace(array("\n","\r"), array('',''),$Text);
|
||||
|
||||
|
||||
|
||||
// Set up the parameters for a URL search string
|
||||
$URLSearchString = "^\[\]";
|
||||
// Set up the parameters for a MAIL search string
|
||||
|
|
|
@ -282,6 +282,11 @@ function relative_date($posted_date,$format = null) {
|
|||
return t('less than a second ago');
|
||||
}
|
||||
|
||||
$time_append = '';
|
||||
if ($etime >= 86400) {
|
||||
$time_append = ' ('.$localtime.')';
|
||||
}
|
||||
|
||||
$a = array( 12 * 30 * 24 * 60 * 60 => array( t('year'), t('years')),
|
||||
30 * 24 * 60 * 60 => array( t('month'), t('months')),
|
||||
7 * 24 * 60 * 60 => array( t('week'), t('weeks')),
|
||||
|
@ -298,7 +303,7 @@ function relative_date($posted_date,$format = null) {
|
|||
// translators - e.g. 22 hours ago, 1 minute ago
|
||||
if(! $format)
|
||||
$format = t('%1$d %2$s ago');
|
||||
return sprintf( $format,$r, (($r == 1) ? $str[0] : $str[1]));
|
||||
return sprintf( $format,$r, (($r == 1) ? $str[0] : $str[1])).$time_append;
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
<?php
|
||||
|
||||
# if PDO is avaible for mysql, use the new database abstraction
|
||||
# TODO: PDO is disabled for release 3.3. We need to investigate why
|
||||
# the update from 3.2 fails with pdo
|
||||
/*
|
||||
if(class_exists('\PDO') && in_array('mysql', PDO::getAvailableDrivers())) {
|
||||
require_once("library/dddbl2/dddbl.php");
|
||||
require_once("include/dba_pdo.php");
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
require_once('include/datetime.php');
|
||||
|
||||
|
@ -14,12 +19,12 @@ require_once('include/datetime.php');
|
|||
*
|
||||
* For debugging, insert 'dbg(1);' anywhere in the program flow.
|
||||
* dbg(0); will turn it off. Logging is performed at LOGGER_DATA level.
|
||||
* When logging, all binary info is converted to text and html entities are escaped so that
|
||||
* When logging, all binary info is converted to text and html entities are escaped so that
|
||||
* the debugging stream is safe to view within both terminals and web pages.
|
||||
*
|
||||
*/
|
||||
|
||||
if(! class_exists('dba')) {
|
||||
|
||||
if(! class_exists('dba')) {
|
||||
class dba {
|
||||
|
||||
private $debug = 0;
|
||||
|
@ -227,7 +232,7 @@ class dba {
|
|||
}
|
||||
|
||||
function __destruct() {
|
||||
if ($this->db)
|
||||
if ($this->db)
|
||||
if($this->mysqli)
|
||||
$this->db->close();
|
||||
else
|
||||
|
@ -245,14 +250,14 @@ function printable($s) {
|
|||
}}
|
||||
|
||||
// Procedural functions
|
||||
if(! function_exists('dbg')) {
|
||||
if(! function_exists('dbg')) {
|
||||
function dbg($state) {
|
||||
global $db;
|
||||
if($db)
|
||||
$db->dbg($state);
|
||||
}}
|
||||
|
||||
if(! function_exists('dbesc')) {
|
||||
if(! function_exists('dbesc')) {
|
||||
function dbesc($str) {
|
||||
global $db;
|
||||
if($db && $db->connected)
|
||||
|
@ -268,7 +273,7 @@ function dbesc($str) {
|
|||
// Example: $r = q("SELECT * FROM `%s` WHERE `uid` = %d",
|
||||
// 'user', 1);
|
||||
|
||||
if(! function_exists('q')) {
|
||||
if(! function_exists('q')) {
|
||||
function q($sql) {
|
||||
|
||||
global $db;
|
||||
|
@ -285,12 +290,12 @@ function q($sql) {
|
|||
|
||||
/**
|
||||
*
|
||||
* This will happen occasionally trying to store the
|
||||
* session data after abnormal program termination
|
||||
* This will happen occasionally trying to store the
|
||||
* session data after abnormal program termination
|
||||
*
|
||||
*/
|
||||
logger('dba: no database: ' . print_r($args,true));
|
||||
return false;
|
||||
return false;
|
||||
|
||||
}}
|
||||
|
||||
|
@ -300,7 +305,7 @@ function q($sql) {
|
|||
*
|
||||
*/
|
||||
|
||||
if(! function_exists('dbq')) {
|
||||
if(! function_exists('dbq')) {
|
||||
function dbq($sql) {
|
||||
|
||||
global $db;
|
||||
|
@ -312,10 +317,10 @@ function dbq($sql) {
|
|||
}}
|
||||
|
||||
|
||||
// Caller is responsible for ensuring that any integer arguments to
|
||||
// Caller is responsible for ensuring that any integer arguments to
|
||||
// dbesc_array are actually integers and not malformed strings containing
|
||||
// SQL injection vectors. All integer array elements should be specifically
|
||||
// cast to int to avoid trouble.
|
||||
// SQL injection vectors. All integer array elements should be specifically
|
||||
// cast to int to avoid trouble.
|
||||
|
||||
|
||||
if(! function_exists('dbesc_array_cb')) {
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -249,6 +249,12 @@ function email_header_encode($in_str, $charset) {
|
|||
return $out_str;
|
||||
}
|
||||
|
||||
/**
|
||||
* email_send is used by NETWORK_EMAIL and NETWORK_EMAIL2 code
|
||||
* (not to notify the user, but to send items to email contacts
|
||||
*
|
||||
* TODO: this could be changed to use the Emailer class
|
||||
*/
|
||||
function email_send($addr, $subject, $headers, $item) {
|
||||
//$headers .= 'MIME-Version: 1.0' . "\n";
|
||||
//$headers .= 'Content-Type: text/html; charset=UTF-8' . "\n";
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
require_once('include/Emailer.php');
|
||||
require_once('include/email.php');
|
||||
require_once('include/bbcode.php');
|
||||
require_once('include/html2bbcode.php');
|
||||
|
||||
function notification($params) {
|
||||
|
||||
logger('notification: entry', LOGGER_DEBUG);
|
||||
#logger('notification()', LOGGER_DEBUG);
|
||||
|
||||
$a = get_app();
|
||||
|
||||
|
@ -26,8 +28,13 @@ function notification($params) {
|
|||
$hostname = substr($hostname,0,strpos($hostname,':'));
|
||||
|
||||
$sender_email = t('noreply') . '@' . $hostname;
|
||||
$additional_mail_header = "";
|
||||
|
||||
// with $params['show_in_notification_page'] == false, the notification isn't inserted into
|
||||
// the database, and an email is sent if applicable.
|
||||
// default, if not specified: true
|
||||
$show_in_notification_page = ((x($params,'show_in_notification_page')) ? $params['show_in_notification_page']:True);
|
||||
|
||||
$additional_mail_header = "";
|
||||
$additional_mail_header .= "Precedence: list\n";
|
||||
$additional_mail_header .= "X-Friendica-Host: ".$hostname."\n";
|
||||
$additional_mail_header .= "X-Friendica-Platform: ".FRIENDICA_PLATFORM."\n";
|
||||
|
@ -35,6 +42,7 @@ function notification($params) {
|
|||
$additional_mail_header .= "List-ID: <notification.".$hostname.">\n";
|
||||
$additional_mail_header .= "List-Archive: <".$a->get_baseurl()."/notifications/system>\n";
|
||||
|
||||
|
||||
if(array_key_exists('item',$params)) {
|
||||
$title = $params['item']['title'];
|
||||
$body = $params['item']['body'];
|
||||
|
@ -223,6 +231,30 @@ function notification($params) {
|
|||
$tsitelink = sprintf( $sitelink, $siteurl );
|
||||
$hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
|
||||
$itemlink = $params['link'];
|
||||
|
||||
switch ($params['verb']) {
|
||||
case ACTIVITY_FRIEND:
|
||||
// someone started to share with user (mostly OStatus)
|
||||
$subject = sprintf( t('[Friendica:Notify] A new person is sharing with you'));
|
||||
$preamble = sprintf( t('%1$s is sharing with you at %2$s'), $params['source_name'], $sitename);
|
||||
$epreamble = sprintf( t('%1$s is sharing with you at %2$s'),
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
|
||||
$sitename);
|
||||
break;
|
||||
case ACTIVITY_FOLLOW:
|
||||
// someone started to follow the user (mostly OStatus)
|
||||
$subject = sprintf( t('[Friendica:Notify] You have a new follower'));
|
||||
$preamble = sprintf( t('You have a new follower at %2$s : %1$s'), $params['source_name'], $sitename);
|
||||
$epreamble = sprintf( t('You have a new follower at %2$s : %1$s'),
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
|
||||
$sitename);
|
||||
break;
|
||||
default:
|
||||
// ACTIVITY_REQ_FRIEND is default activity for notifications
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if($params['type'] == NOTIFY_SUGGEST) {
|
||||
|
@ -244,12 +276,76 @@ function notification($params) {
|
|||
}
|
||||
|
||||
if($params['type'] == NOTIFY_CONFIRM) {
|
||||
if ($params['verb'] == ACTIVITY_FRIEND ){ // mutual connection
|
||||
$subject = sprintf( t('[Friendica:Notify] Connection accepted'));
|
||||
$preamble = sprintf( t('\'%1$s\' has acepted your connection request at %2$s'), $params['source_name'], $sitename);
|
||||
$epreamble = sprintf( t('%2$s has accepted your [url=%1$s]connection request[/url].'),
|
||||
$itemlink,
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
|
||||
$body = t('You are now mutual friends and may exchange status updates, photos, and email
|
||||
without restriction.');
|
||||
|
||||
$sitelink = t('Please visit %s if you wish to make any changes to this relationship.');
|
||||
$tsitelink = sprintf( $sitelink, $siteurl );
|
||||
$hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
|
||||
$itemlink = $params['link'];
|
||||
} else { // ACTIVITY_FOLLOW
|
||||
$subject = sprintf( t('[Friendica:Notify] Connection accepted'));
|
||||
$preamble = sprintf( t('\'%1$s\' has acepted your connection request at %2$s'), $params['source_name'], $sitename);
|
||||
$epreamble = sprintf( t('%2$s has accepted your [url=%1$s]connection request[/url].'),
|
||||
$itemlink,
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
|
||||
$body = sprintf(t('\'%1$s\' has chosen to accept you a "fan", which restricts some forms of communication - such as private messaging and some profile interactions. If this is a celebrity or community page, these settings were applied automatically.'), $params['source_name']);
|
||||
$body .= "\n\n";
|
||||
$body .= sprintf(t('\'%1$s\' may choose to extend this into a two-way or more permissive relationship in the future. '), $params['source_name']);
|
||||
|
||||
$sitelink = t('Please visit %s if you wish to make any changes to this relationship.');
|
||||
$tsitelink = sprintf( $sitelink, $siteurl );
|
||||
$hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
|
||||
$itemlink = $params['link'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($params['type'] == NOTIFY_SYSTEM) {
|
||||
switch($params['event']) {
|
||||
case "SYSTEM_REGISTER_REQUEST":
|
||||
$subject = sprintf( t('[Friendica System:Notify] registration request'));
|
||||
$preamble = sprintf( t('You\'ve received a registration request from \'%1$s\' at %2$s'), $params['source_name'], $sitename);
|
||||
$epreamble = sprintf( t('You\'ve received a [url=%1$s]registration request[/url] from %2$s.'),
|
||||
$itemlink,
|
||||
'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
|
||||
$body = sprintf( t('Full Name: %1$s\nSite Location: %2$s\nLogin Name: %3$s (%4$s)'),
|
||||
$params['source_name'], $siteurl, $params['source_mail'], $params['source_nick']);
|
||||
|
||||
$sitelink = t('Please visit %s to approve or reject the request.');
|
||||
$tsitelink = sprintf( $sitelink, $params['link'] );
|
||||
$hsitelink = sprintf( $sitelink, '<a href="' . $params['link'] . '">' . $sitename . '</a><br><br>');
|
||||
$itemlink = $params['link'];
|
||||
break;
|
||||
case "SYSTEM_DB_UPDATE_FAIL":
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($params['type'] == "SYSTEM_EMAIL"){
|
||||
// not part of the notifications.
|
||||
// it just send a mail to the user.
|
||||
// It will be used by the system to send emails to users (like
|
||||
// password reset, invitations and so) using one look (but without
|
||||
// add a notification to the user, with could be inexistent)
|
||||
$subject = $params['subject'];
|
||||
$preamble = $params['preamble'];
|
||||
$body = $params['body'];
|
||||
$sitelink = "";
|
||||
$tsitelink = "";
|
||||
$hsitelink = "";
|
||||
$itemlink = "";
|
||||
$show_in_notification_page = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$h = array(
|
||||
'params' => $params,
|
||||
'subject' => $subject,
|
||||
|
@ -274,114 +370,110 @@ function notification($params) {
|
|||
$itemlink = $h['itemlink'];
|
||||
|
||||
|
||||
require_once('include/html2bbcode.php');
|
||||
|
||||
do {
|
||||
$dups = false;
|
||||
$hash = random_string();
|
||||
$r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1",
|
||||
dbesc($hash));
|
||||
if(count($r))
|
||||
$dups = true;
|
||||
} while($dups == true);
|
||||
if ($show_in_notification_page) {
|
||||
logger("adding notification entry", LOGGER_DEBUG);
|
||||
do {
|
||||
$dups = false;
|
||||
$hash = random_string();
|
||||
$r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1",
|
||||
dbesc($hash));
|
||||
if(count($r))
|
||||
$dups = true;
|
||||
} while($dups == true);
|
||||
|
||||
|
||||
$datarray = array();
|
||||
$datarray['hash'] = $hash;
|
||||
$datarray['name'] = $params['source_name'];
|
||||
$datarray['url'] = $params['source_link'];
|
||||
$datarray['photo'] = $params['source_photo'];
|
||||
$datarray['date'] = datetime_convert();
|
||||
$datarray['uid'] = $params['uid'];
|
||||
$datarray['link'] = $itemlink;
|
||||
$datarray['parent'] = $parent_id;
|
||||
$datarray['type'] = $params['type'];
|
||||
$datarray['verb'] = $params['verb'];
|
||||
$datarray['otype'] = $params['otype'];
|
||||
$datarray['abort'] = false;
|
||||
$datarray = array();
|
||||
$datarray['hash'] = $hash;
|
||||
$datarray['name'] = $params['source_name'];
|
||||
$datarray['url'] = $params['source_link'];
|
||||
$datarray['photo'] = $params['source_photo'];
|
||||
$datarray['date'] = datetime_convert();
|
||||
$datarray['uid'] = $params['uid'];
|
||||
$datarray['link'] = $itemlink;
|
||||
$datarray['parent'] = $parent_id;
|
||||
$datarray['type'] = $params['type'];
|
||||
$datarray['verb'] = $params['verb'];
|
||||
$datarray['otype'] = $params['otype'];
|
||||
$datarray['abort'] = false;
|
||||
|
||||
call_hooks('enotify_store', $datarray);
|
||||
call_hooks('enotify_store', $datarray);
|
||||
|
||||
if($datarray['abort']) {
|
||||
pop_lang();
|
||||
return;
|
||||
}
|
||||
|
||||
// create notification entry in DB
|
||||
|
||||
$r = q("insert into notify (hash,name,url,photo,date,uid,link,parent,type,verb,otype)
|
||||
values('%s','%s','%s','%s','%s',%d,'%s',%d,%d,'%s','%s')",
|
||||
dbesc($datarray['hash']),
|
||||
dbesc($datarray['name']),
|
||||
dbesc($datarray['url']),
|
||||
dbesc($datarray['photo']),
|
||||
dbesc($datarray['date']),
|
||||
intval($datarray['uid']),
|
||||
dbesc($datarray['link']),
|
||||
intval($datarray['parent']),
|
||||
intval($datarray['type']),
|
||||
dbesc($datarray['verb']),
|
||||
dbesc($datarray['otype'])
|
||||
);
|
||||
|
||||
$r = q("select id from notify where hash = '%s' and uid = %d limit 1",
|
||||
dbesc($hash),
|
||||
intval($params['uid'])
|
||||
);
|
||||
if($r)
|
||||
$notify_id = $r[0]['id'];
|
||||
else {
|
||||
pop_lang();
|
||||
return;
|
||||
}
|
||||
|
||||
// we seem to have a lot of duplicate comment notifications due to race conditions, mostly from forums
|
||||
// After we've stored everything, look again to see if there are any duplicates and if so remove them
|
||||
|
||||
$p = null;
|
||||
$p = q("select id from notify where ( type = %d or type = %d ) and link = '%s' and uid = %d order by id",
|
||||
intval(NOTIFY_TAGSELF),
|
||||
intval(NOTIFY_COMMENT),
|
||||
dbesc($params['link']),
|
||||
intval($params['uid'])
|
||||
);
|
||||
if($p && (count($p) > 1)) {
|
||||
for ($d = 1; $d < count($p); $d ++) {
|
||||
q("delete from notify where id = %d",
|
||||
intval($p[$d]['id'])
|
||||
);
|
||||
}
|
||||
|
||||
// only continue on if we stored the first one
|
||||
|
||||
if($notify_id != $p[0]['id']) {
|
||||
if($datarray['abort']) {
|
||||
pop_lang();
|
||||
return;
|
||||
return False;
|
||||
}
|
||||
|
||||
// create notification entry in DB
|
||||
|
||||
$r = q("insert into notify (hash,name,url,photo,date,uid,link,parent,type,verb,otype)
|
||||
values('%s','%s','%s','%s','%s',%d,'%s',%d,%d,'%s','%s')",
|
||||
dbesc($datarray['hash']),
|
||||
dbesc($datarray['name']),
|
||||
dbesc($datarray['url']),
|
||||
dbesc($datarray['photo']),
|
||||
dbesc($datarray['date']),
|
||||
intval($datarray['uid']),
|
||||
dbesc($datarray['link']),
|
||||
intval($datarray['parent']),
|
||||
intval($datarray['type']),
|
||||
dbesc($datarray['verb']),
|
||||
dbesc($datarray['otype'])
|
||||
);
|
||||
|
||||
$r = q("select id from notify where hash = '%s' and uid = %d limit 1",
|
||||
dbesc($hash),
|
||||
intval($params['uid'])
|
||||
);
|
||||
if($r)
|
||||
$notify_id = $r[0]['id'];
|
||||
else {
|
||||
pop_lang();
|
||||
return False;
|
||||
}
|
||||
|
||||
// we seem to have a lot of duplicate comment notifications due to race conditions, mostly from forums
|
||||
// After we've stored everything, look again to see if there are any duplicates and if so remove them
|
||||
|
||||
$p = null;
|
||||
$p = q("select id from notify where ( type = %d or type = %d ) and link = '%s' and uid = %d order by id",
|
||||
intval(NOTIFY_TAGSELF),
|
||||
intval(NOTIFY_COMMENT),
|
||||
dbesc($params['link']),
|
||||
intval($params['uid'])
|
||||
);
|
||||
if($p && (count($p) > 1)) {
|
||||
for ($d = 1; $d < count($p); $d ++) {
|
||||
q("delete from notify where id = %d",
|
||||
intval($p[$d]['id'])
|
||||
);
|
||||
}
|
||||
|
||||
// only continue on if we stored the first one
|
||||
|
||||
if($notify_id != $p[0]['id']) {
|
||||
pop_lang();
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$itemlink = $a->get_baseurl() . '/notify/view/' . $notify_id;
|
||||
$msg = replace_macros($epreamble,array('$itemlink' => $itemlink));
|
||||
$r = q("update notify set msg = '%s' where id = %d and uid = %d",
|
||||
dbesc($msg),
|
||||
intval($notify_id),
|
||||
intval($params['uid'])
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$itemlink = $a->get_baseurl() . '/notify/view/' . $notify_id;
|
||||
$msg = replace_macros($epreamble,array('$itemlink' => $itemlink));
|
||||
$r = q("update notify set msg = '%s' where id = %d and uid = %d",
|
||||
dbesc($msg),
|
||||
intval($notify_id),
|
||||
intval($params['uid'])
|
||||
);
|
||||
|
||||
|
||||
// send email notification if notification preferences permit
|
||||
if((intval($params['notify_flags']) & intval($params['type']))
|
||||
|| $params['type'] == NOTIFY_SYSTEM
|
||||
|| $params['type'] == "SYSTEM_EMAIL") {
|
||||
|
||||
require_once('include/bbcode.php');
|
||||
if((intval($params['notify_flags']) & intval($params['type'])) || $params['type'] == NOTIFY_SYSTEM) {
|
||||
|
||||
logger('notification: sending notification email');
|
||||
logger('sending notification email');
|
||||
|
||||
if (isset($params['parent']) AND (intval($params['parent']) != 0)) {
|
||||
$id_for_parent = $params['parent']."@".$hostname;
|
||||
|
@ -410,16 +502,18 @@ function notification($params) {
|
|||
} else {
|
||||
// If not, just "follow" the thread.
|
||||
$additional_mail_header .= "References: <${id_for_parent}>\nIn-Reply-To: <${id_for_parent}>\n";
|
||||
logger("include/enotify: There's already a notification for this parent:\n" . print_r($r, true), LOGGER_DEBUG);
|
||||
logger("There's already a notification for this parent:\n" . print_r($r, true), LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$textversion = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n",
|
||||
$body))),ENT_QUOTES,'UTF-8'));
|
||||
// textversion keeps linebreaks
|
||||
$textversion = strip_tags(str_replace("<br>","\n",html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n",
|
||||
$body))),ENT_QUOTES,'UTF-8')));
|
||||
$htmlversion = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"),
|
||||
"<br />\n",$body))),ENT_QUOTES,'UTF-8');
|
||||
|
||||
|
||||
$datarray = array();
|
||||
$datarray['banner'] = $banner;
|
||||
$datarray['product'] = $product;
|
||||
|
@ -448,14 +542,15 @@ function notification($params) {
|
|||
call_hooks('enotify_mail', $datarray);
|
||||
|
||||
// check whether sending post content in email notifications is allowed
|
||||
$content_allowed = !get_config('system','enotify_no_content');
|
||||
// always true for "SYSTEM_EMAIL"
|
||||
$content_allowed = ((!get_config('system','enotify_no_content')) || ($params['type'] == "SYSTEM_EMAIL"));
|
||||
|
||||
// load the template for private message notifications
|
||||
$tpl = get_markup_template('email_notify_html.tpl');
|
||||
$email_html_body = replace_macros($tpl,array(
|
||||
'$banner' => $datarray['banner'],
|
||||
'$product' => $datarray['product'],
|
||||
'$preamble' => $datarray['preamble'],
|
||||
'$preamble' => str_replace("\n","<br>\n",$datarray['preamble']),
|
||||
'$sitename' => $datarray['sitename'],
|
||||
'$siteurl' => $datarray['siteurl'],
|
||||
'$source_name' => $datarray['source_name'],
|
||||
|
@ -494,9 +589,9 @@ function notification($params) {
|
|||
|
||||
// logger('text: ' . $email_text_body);
|
||||
|
||||
// use the EmailNotification library to send the message
|
||||
// use the Emailer class to send the message
|
||||
|
||||
enotify::send(array(
|
||||
return Emailer::send(array(
|
||||
'fromName' => $sender_name,
|
||||
'fromEmail' => $sender_email,
|
||||
'replyTo' => $sender_email,
|
||||
|
@ -508,67 +603,8 @@ function notification($params) {
|
|||
));
|
||||
}
|
||||
|
||||
pop_lang();
|
||||
return False;
|
||||
|
||||
}
|
||||
|
||||
require_once('include/email.php');
|
||||
|
||||
class enotify {
|
||||
/**
|
||||
* Send a multipart/alternative message with Text and HTML versions
|
||||
*
|
||||
* @param fromName name of the sender
|
||||
* @param fromEmail email fo the sender
|
||||
* @param replyTo replyTo address to direct responses
|
||||
* @param toEmail destination email address
|
||||
* @param messageSubject subject of the message
|
||||
* @param htmlVersion html version of the message
|
||||
* @param textVersion text only version of the message
|
||||
* @param additionalMailHeader additions to the smtp mail header
|
||||
*/
|
||||
static public function send($params) {
|
||||
|
||||
$fromName = email_header_encode(html_entity_decode($params['fromName'],ENT_QUOTES,'UTF-8'),'UTF-8');
|
||||
$messageSubject = email_header_encode(html_entity_decode($params['messageSubject'],ENT_QUOTES,'UTF-8'),'UTF-8');
|
||||
|
||||
// generate a mime boundary
|
||||
$mimeBoundary =rand(0,9)."-"
|
||||
.rand(10000000000,9999999999)."-"
|
||||
.rand(10000000000,9999999999)."=:"
|
||||
.rand(10000,99999);
|
||||
|
||||
// generate a multipart/alternative message header
|
||||
$messageHeader =
|
||||
$params['additionalMailHeader'] .
|
||||
"From: $fromName <{$params['fromEmail']}>\n" .
|
||||
"Reply-To: $fromName <{$params['replyTo']}>\n" .
|
||||
"MIME-Version: 1.0\n" .
|
||||
"Content-Type: multipart/alternative; boundary=\"{$mimeBoundary}\"";
|
||||
|
||||
// assemble the final multipart message body with the text and html types included
|
||||
$textBody = chunk_split(base64_encode($params['textVersion']));
|
||||
$htmlBody = chunk_split(base64_encode($params['htmlVersion']));
|
||||
$multipartMessageBody =
|
||||
"--" . $mimeBoundary . "\n" . // plain text section
|
||||
"Content-Type: text/plain; charset=UTF-8\n" .
|
||||
"Content-Transfer-Encoding: base64\n\n" .
|
||||
$textBody . "\n" .
|
||||
"--" . $mimeBoundary . "\n" . // text/html section
|
||||
"Content-Type: text/html; charset=UTF-8\n" .
|
||||
"Content-Transfer-Encoding: base64\n\n" .
|
||||
$htmlBody . "\n" .
|
||||
"--" . $mimeBoundary . "--\n"; // message ending
|
||||
|
||||
// send the message
|
||||
$res = mail(
|
||||
$params['toEmail'], // send to address
|
||||
$messageSubject, // subject
|
||||
$multipartMessageBody, // message body
|
||||
$messageHeader // message headers
|
||||
);
|
||||
logger("notification: enotify::send header " . 'To: ' . $params['toEmail'] . "\n" . $messageHeader, LOGGER_DEBUG);
|
||||
logger("notification: enotify::send returns " . $res, LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -872,7 +872,7 @@ function get_atom_elements($feed, $item, $contact = array()) {
|
|||
}
|
||||
|
||||
if (isset($contact["network"]) AND ($contact["network"] == NETWORK_FEED) AND $contact['fetch_further_information']) {
|
||||
$res["body"] = $res["title"].add_page_info($res['plink']);
|
||||
$res["body"] = $res["title"].add_page_info($res['plink'], false, "", ($contact['fetch_further_information'] == 2), $contact['ffi_keyword_blacklist']);
|
||||
$res["title"] = "";
|
||||
$res["object-type"] = ACTIVITY_OBJ_BOOKMARK;
|
||||
} elseif (isset($contact["network"]) AND ($contact["network"] == NETWORK_OSTATUS))
|
||||
|
@ -888,12 +888,8 @@ function get_atom_elements($feed, $item, $contact = array()) {
|
|||
return $res;
|
||||
}
|
||||
|
||||
function add_page_info($url, $no_photos = false, $photo = "") {
|
||||
require_once("mod/parse_url.php");
|
||||
|
||||
$data = parseurl_getsiteinfo($url, true);
|
||||
|
||||
logger('add_page_info: fetch page info for '.$url.' '.print_r($data, true), LOGGER_DEBUG);
|
||||
function add_page_info_data($data) {
|
||||
call_hooks('page_info_data', $data);
|
||||
|
||||
// It maybe is a rich content, but if it does have everything that a link has,
|
||||
// then treat it that way
|
||||
|
@ -908,7 +904,7 @@ function add_page_info($url, $no_photos = false, $photo = "") {
|
|||
return("");
|
||||
|
||||
if (($data["type"] != "photo") AND is_string($data["title"]))
|
||||
$text .= "[bookmark=".$url."]".trim($data["title"])."[/bookmark]";
|
||||
$text .= "[bookmark=".$data["url"]."]".trim($data["title"])."[/bookmark]";
|
||||
|
||||
if (($data["type"] != "video") AND ($photo != ""))
|
||||
$text .= '[img]'.$photo.'[/img]';
|
||||
|
@ -920,7 +916,43 @@ function add_page_info($url, $no_photos = false, $photo = "") {
|
|||
if (($data["type"] != "photo") AND is_string($data["text"]))
|
||||
$text .= "[quote]".$data["text"]."[/quote]";
|
||||
|
||||
return("\n[class=type-".$data["type"]."]".$text."[/class]");
|
||||
$hashtags = "";
|
||||
if (isset($data["keywords"]) AND count($data["keywords"])) {
|
||||
$a = get_app();
|
||||
$hashtags = "\n";
|
||||
foreach ($data["keywords"] AS $keyword) {
|
||||
$hashtag = str_replace(array(" ", "+", "/", ".", "#", "'"),
|
||||
array("","", "", "", "", ""), $keyword);
|
||||
$hashtags .= "#[url=".$a->get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url] ";
|
||||
}
|
||||
}
|
||||
|
||||
return("\n[class=type-".$data["type"]."]".$text."[/class]".$hashtags);
|
||||
}
|
||||
|
||||
function add_page_info($url, $no_photos = false, $photo = "", $keywords = false, $keyword_blacklist = "") {
|
||||
require_once("mod/parse_url.php");
|
||||
|
||||
$data = parseurl_getsiteinfo($url, true);
|
||||
|
||||
logger('add_page_info: fetch page info for '.$url.' '.print_r($data, true), LOGGER_DEBUG);
|
||||
|
||||
if (!$keywords AND isset($data["keywords"]))
|
||||
unset($data["keywords"]);
|
||||
|
||||
if (($keyword_blacklist != "") AND isset($data["keywords"])) {
|
||||
$list = explode(",", $keyword_blacklist);
|
||||
foreach ($list AS $keyword) {
|
||||
$keyword = trim($keyword);
|
||||
$index = array_search($keyword, $data["keywords"]);
|
||||
if ($index !== false)
|
||||
unset($data["keywords"][$index]);
|
||||
}
|
||||
}
|
||||
|
||||
$text = add_page_info_data($data);
|
||||
|
||||
return($text);
|
||||
}
|
||||
|
||||
function add_page_info_to_body($body, $texturl = false, $no_photos = false) {
|
||||
|
@ -1129,6 +1161,11 @@ function item_store($arr,$force_parent = false, $notify = false) {
|
|||
$arr['origin'] = ((x($arr,'origin')) ? intval($arr['origin']) : 0 );
|
||||
$arr['guid'] = ((x($arr,'guid')) ? notags(trim($arr['guid'])) : get_guid(30));
|
||||
$arr['network'] = ((x($arr,'network')) ? trim($arr['network']) : '');
|
||||
$arr['postopts'] = ((x($arr,'postopts')) ? trim($arr['postopts']) : '');
|
||||
$arr['resource-id'] = ((x($arr,'resource-id')) ? trim($arr['resource-id']) : '');
|
||||
$arr['event-id'] = ((x($arr,'event-id')) ? intval($arr['event-id']) : 0 );
|
||||
$arr['inform'] = ((x($arr,'inform')) ? trim($arr['inform']) : '');
|
||||
$arr['file'] = ((x($arr,'file')) ? trim($arr['file']) : '');
|
||||
|
||||
if ($arr['plink'] == "") {
|
||||
$a = get_app();
|
||||
|
@ -1412,7 +1449,7 @@ function item_store($arr,$force_parent = false, $notify = false) {
|
|||
if (!$deleted) {
|
||||
|
||||
// Store the fresh generated item into the cache
|
||||
$cachefile = get_cachefile($arr["guid"]."-".hash("md5", $arr['body']));
|
||||
$cachefile = get_cachefile(urlencode($arr["guid"])."-".hash("md5", $arr['body']));
|
||||
|
||||
if (($cachefile != '') AND !file_exists($cachefile)) {
|
||||
$s = prepare_text($arr['body']);
|
||||
|
@ -1938,6 +1975,7 @@ function edited_timestamp_is_newer($existing, $update) {
|
|||
function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) {
|
||||
|
||||
require_once('library/simplepie/simplepie.inc');
|
||||
require_once('include/contact_selectors.php');
|
||||
|
||||
if(! strlen($xml)) {
|
||||
logger('consume_feed: empty input');
|
||||
|
@ -2576,31 +2614,10 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
|||
|
||||
// This is my contact on another system, but it's really me.
|
||||
// Turn this into a wall post.
|
||||
|
||||
if($contact['remote_self']) {
|
||||
if ($contact['remote_self'] == 2) {
|
||||
$r = q("SELECT `id`,`url`,`name`,`photo`,`network` FROM `contact` WHERE `uid` = %d AND `self`", intval($importer['uid']));
|
||||
if (count($r)) {
|
||||
$datarray['contact-id'] = $r[0]["id"];
|
||||
|
||||
$datarray['owner-name'] = $r[0]["name"];
|
||||
$datarray['owner-link'] = $r[0]["url"];
|
||||
$datarray['owner-avatar'] = $r[0]["photo"];
|
||||
|
||||
$datarray['author-name'] = $datarray['owner-name'];
|
||||
$datarray['author-link'] = $datarray['owner-link'];
|
||||
$datarray['author-avatar'] = $datarray['owner-avatar'];
|
||||
}
|
||||
}
|
||||
|
||||
$notify = true;
|
||||
if($contact['network'] === NETWORK_FEED) {
|
||||
$datarray['private'] = 0;
|
||||
}
|
||||
} else
|
||||
$notify = false;
|
||||
$notify = item_is_remote_self($contact, $datarray);
|
||||
|
||||
$r = item_store($datarray, false, $notify);
|
||||
logger('Stored - Contact '.$contact['url'].' Notify '.$notify.' return '.$r.' Item '.print_r($datarray, true), LOGGER_DEBUG);
|
||||
continue;
|
||||
|
||||
}
|
||||
|
@ -2608,10 +2625,69 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
|||
}
|
||||
}
|
||||
|
||||
function item_is_remote_self($contact, &$datarray) {
|
||||
$a = get_app();
|
||||
|
||||
if (!$contact['remote_self'])
|
||||
return false;
|
||||
|
||||
// Prevent the forwarding of posts that are forwarded
|
||||
if ($datarray["extid"] == NETWORK_DFRN)
|
||||
return false;
|
||||
|
||||
// Prevent to forward already forwarded posts
|
||||
if ($datarray["app"] == $a->get_hostname())
|
||||
return false;
|
||||
|
||||
if (($contact['network'] != NETWORK_FEED) AND $datarray['private'])
|
||||
return false;
|
||||
|
||||
$datarray2 = $datarray;
|
||||
logger('remote-self start - Contact '.$contact['url'].' - '.$contact['remote_self'].' Item '.print_r($datarray, true), LOGGER_DEBUG);
|
||||
if ($contact['remote_self'] == 2) {
|
||||
$r = q("SELECT `id`,`url`,`name`,`photo`,`network` FROM `contact` WHERE `uid` = %d AND `self`",
|
||||
intval($contact['uid']));
|
||||
if (count($r)) {
|
||||
$datarray['contact-id'] = $r[0]["id"];
|
||||
|
||||
$datarray['owner-name'] = $r[0]["name"];
|
||||
$datarray['owner-link'] = $r[0]["url"];
|
||||
$datarray['owner-avatar'] = $r[0]["avatar"];
|
||||
|
||||
$datarray['author-name'] = $datarray['owner-name'];
|
||||
$datarray['author-link'] = $datarray['owner-link'];
|
||||
$datarray['author-avatar'] = $datarray['owner-avatar'];
|
||||
}
|
||||
|
||||
if ($contact['network'] != NETWORK_FEED) {
|
||||
$datarray["guid"] = get_guid(32);
|
||||
unset($datarray["plink"]);
|
||||
$datarray["uri"] = item_new_uri($a->get_hostname(),$contact['uid']);
|
||||
$datarray["parent-uri"] = $datarray["uri"];
|
||||
$datarray["extid"] = $contact['network'];
|
||||
$urlpart = parse_url($datarray2['author-link']);
|
||||
$datarray["app"] = $urlpart["host"];
|
||||
} else
|
||||
$datarray['private'] = 0;
|
||||
}
|
||||
|
||||
//if (!isset($datarray["app"]) OR ($datarray["app"] == ""))
|
||||
// $datarray["app"] = network_to_name($contact['network']);
|
||||
|
||||
if ($contact['network'] != NETWORK_FEED) {
|
||||
// Store the original post
|
||||
$r = item_store($datarray2, false, false);
|
||||
logger('remote-self post original item - Contact '.$contact['url'].' return '.$r.' Item '.print_r($datarray2, true), LOGGER_DEBUG);
|
||||
} else
|
||||
$datarray["app"] = "Feed";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function local_delivery($importer,$data) {
|
||||
$a = get_app();
|
||||
|
||||
logger(__function__, LOGGER_TRACE);
|
||||
logger(__function__, LOGGER_TRACE);
|
||||
|
||||
if($importer['readonly']) {
|
||||
// We aren't receiving stuff from this person. But we will quietly ignore them
|
||||
|
@ -3689,27 +3765,7 @@ function local_delivery($importer,$data) {
|
|||
|
||||
// This is my contact on another system, but it's really me.
|
||||
// Turn this into a wall post.
|
||||
|
||||
if($importer['remote_self']) {
|
||||
if ($importer['remote_self'] == 2) {
|
||||
$r = q("SELECT `id`,`url`,`name`,`photo`,`network` FROM `contact` WHERE `uid` = %d AND `self`",
|
||||
intval($importer['importer_uid']));
|
||||
if (count($r)) {
|
||||
$datarray['contact-id'] = $r[0]["id"];
|
||||
|
||||
$datarray['owner-name'] = $r[0]["name"];
|
||||
$datarray['owner-link'] = $r[0]["url"];
|
||||
$datarray['owner-avatar'] = $r[0]["photo"];
|
||||
|
||||
$datarray['author-name'] = $datarray['owner-name'];
|
||||
$datarray['author-link'] = $datarray['owner-link'];
|
||||
$datarray['author-avatar'] = $datarray['owner-avatar'];
|
||||
}
|
||||
}
|
||||
|
||||
$notify = true;
|
||||
} else
|
||||
$notify = false;
|
||||
$notify = item_is_remote_self($importer, $datarray);
|
||||
|
||||
$posted_id = item_store($datarray, false, $notify);
|
||||
|
||||
|
@ -3828,6 +3884,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
|
|||
dbesc(datetime_convert())
|
||||
);
|
||||
}
|
||||
|
||||
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
|
||||
intval($importer['uid'])
|
||||
);
|
||||
|
@ -3841,20 +3898,24 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
|
|||
|
||||
if(($r[0]['notify-flags'] & NOTIFY_INTRO) &&
|
||||
(($r[0]['page-flags'] == PAGE_NORMAL) OR ($r[0]['page-flags'] == PAGE_SOAPBOX))) {
|
||||
$email_tpl = get_intltext_template('follow_notify_eml.tpl');
|
||||
$email = replace_macros($email_tpl, array(
|
||||
'$requestor' => ((strlen($name)) ? $name : t('[Name Withheld]')),
|
||||
'$url' => $url,
|
||||
'$myname' => $r[0]['username'],
|
||||
'$siteurl' => $a->get_baseurl(),
|
||||
'$sitename' => $a->config['sitename']
|
||||
|
||||
|
||||
|
||||
notification(array(
|
||||
'type' => NOTIFY_INTRO,
|
||||
'notify_flags' => $r[0]['notify-flags'],
|
||||
'language' => $r[0]['language'],
|
||||
'to_name' => $r[0]['username'],
|
||||
'to_email' => $r[0]['email'],
|
||||
'uid' => $r[0]['uid'],
|
||||
'link' => $a->get_baseurl() . '/notifications/intro',
|
||||
'source_name' => ((strlen(stripslashes($contact_record['name']))) ? stripslashes($contact_record['name']) : t('[Name Withheld]')),
|
||||
'source_link' => $contact_record['url'],
|
||||
'source_photo' => $contact_record['photo'],
|
||||
'verb' => ($sharing ? ACTIVITY_FRIEND : ACTIVITY_FOLLOW),
|
||||
'otype' => 'intro'
|
||||
));
|
||||
$res = mail($r[0]['email'],
|
||||
email_header_encode((($sharing) ? t('A new person is sharing with you at ') : t("You have a new follower at ")) . $a->config['sitename'],'UTF-8'),
|
||||
$email,
|
||||
'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n"
|
||||
. 'Content-type: text/plain; charset=UTF-8' . "\n"
|
||||
. 'Content-transfer-encoding: 8bit' );
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
|
||||
// curl wrapper. If binary flag is true, return binary
|
||||
// results.
|
||||
// results.
|
||||
|
||||
// Set the cookiejar argument to a string (e.g. "/tmp/friendica-cookies.txt")
|
||||
// to preserve cookies from one request to the next.
|
||||
|
@ -24,7 +24,7 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_
|
|||
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar);
|
||||
}
|
||||
|
||||
// These settings aren't needed. We're following the location already.
|
||||
// These settings aren't needed. We're following the location already.
|
||||
// @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
// @curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
|
||||
|
||||
|
@ -35,7 +35,7 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_
|
|||
}
|
||||
|
||||
@curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
|
||||
@curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION."-".DB_UPDATE_VERSION.")");
|
||||
@curl_setopt($ch, CURLOPT_USERAGENT, $a->get_useragent());
|
||||
|
||||
|
||||
if(intval($timeout)) {
|
||||
|
@ -134,7 +134,7 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0)
|
|||
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
|
||||
curl_setopt($ch, CURLOPT_POST,1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION."-".DB_UPDATE_VERSION.")");
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, $a->get_useragent());
|
||||
|
||||
if(intval($timeout)) {
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
||||
|
@ -219,8 +219,8 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0)
|
|||
}}
|
||||
|
||||
// Generic XML return
|
||||
// Outputs a basic dfrn XML status structure to STDOUT, with a <status> variable
|
||||
// of $st and an optional text <message> of $message and terminates the current process.
|
||||
// Outputs a basic dfrn XML status structure to STDOUT, with a <status> variable
|
||||
// of $st and an optional text <message> of $message and terminates the current process.
|
||||
|
||||
if(! function_exists('xml_status')) {
|
||||
function xml_status($st, $message = '') {
|
||||
|
@ -246,7 +246,7 @@ function http_status_exit($val) {
|
|||
if($val >= 200 && $val < 300)
|
||||
$err = 'OK';
|
||||
|
||||
logger('http_status_exit ' . $val);
|
||||
logger('http_status_exit ' . $val);
|
||||
header($_SERVER["SERVER_PROTOCOL"] . ' ' . $val . ' ' . $err);
|
||||
killme();
|
||||
|
||||
|
@ -298,16 +298,16 @@ function convert_xml_element_to_array($xml_element, &$recursion_depth=0) {
|
|||
}
|
||||
}}
|
||||
|
||||
// Given an email style address, perform webfinger lookup and
|
||||
// Given an email style address, perform webfinger lookup and
|
||||
// return the resulting DFRN profile URL, or if no DFRN profile URL
|
||||
// is located, returns an OStatus subscription template (prefixed
|
||||
// is located, returns an OStatus subscription template (prefixed
|
||||
// with the string 'stat:' to identify it as on OStatus template).
|
||||
// If this isn't an email style address just return $s.
|
||||
// Return an empty string if email-style addresses but webfinger fails,
|
||||
// or if the resultant personal XRD doesn't contain a supported
|
||||
// or if the resultant personal XRD doesn't contain a supported
|
||||
// subscription/friend-request attribute.
|
||||
|
||||
// amended 7/9/2011 to return an hcard which could save potentially loading
|
||||
// amended 7/9/2011 to return an hcard which could save potentially loading
|
||||
// a lengthy content page to scrape dfrn attributes
|
||||
|
||||
if(! function_exists('webfinger_dfrn')) {
|
||||
|
@ -332,7 +332,7 @@ function webfinger_dfrn($s,&$hcard) {
|
|||
return $profile_link;
|
||||
}}
|
||||
|
||||
// Given an email style address, perform webfinger lookup and
|
||||
// Given an email style address, perform webfinger lookup and
|
||||
// return the array of link attributes from the personal XRD file.
|
||||
// On error/failure return an empty array.
|
||||
|
||||
|
@ -374,7 +374,7 @@ function lrdd($uri, $debug = false) {
|
|||
// All we have is an email address. Resource-priority is irrelevant
|
||||
// because our URI isn't directly resolvable.
|
||||
|
||||
if(strstr($uri,'@')) {
|
||||
if(strstr($uri,'@')) {
|
||||
return(webfinger($uri));
|
||||
}
|
||||
|
||||
|
@ -418,7 +418,7 @@ function lrdd($uri, $debug = false) {
|
|||
foreach($properties as $prop)
|
||||
if((string) $prop['@attributes'] === 'http://lrdd.net/priority/resource')
|
||||
$priority = 'resource';
|
||||
}
|
||||
}
|
||||
|
||||
// save the links in case we need them
|
||||
|
||||
|
@ -449,7 +449,7 @@ function lrdd($uri, $debug = false) {
|
|||
$tpl = '';
|
||||
|
||||
if($priority === 'host') {
|
||||
if(strlen($tpl))
|
||||
if(strlen($tpl))
|
||||
$pxrd = str_replace('{uri}', urlencode($uri), $tpl);
|
||||
elseif(isset($href))
|
||||
$pxrd = $href;
|
||||
|
@ -623,6 +623,9 @@ function fetch_xrd_links($url) {
|
|||
|
||||
if(! function_exists('validate_url')) {
|
||||
function validate_url(&$url) {
|
||||
|
||||
if(get_config('system','disable_url_validation'))
|
||||
return true;
|
||||
// no naked subdomains (allow localhost for tests)
|
||||
if(strpos($url,'.') === false && strpos($url,'/localhost/') === false)
|
||||
return false;
|
||||
|
@ -688,7 +691,7 @@ function allowed_url($url) {
|
|||
foreach($allowed as $a) {
|
||||
$pat = strtolower(trim($a));
|
||||
if(($fnmatch && fnmatch($pat,$host)) || ($pat == $host)) {
|
||||
$found = true;
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -722,7 +725,7 @@ function allowed_email($email) {
|
|||
foreach($allowed as $a) {
|
||||
$pat = strtolower(trim($a));
|
||||
if(($fnmatch && fnmatch($pat,$domain)) || ($pat == $domain)) {
|
||||
$found = true;
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -888,7 +891,7 @@ function scale_external_images($srctext, $include_link = true, $scale_replace =
|
|||
$new_height = $ph->getHeight();
|
||||
logger('scale_external_images: ' . $orig_width . '->' . $new_width . 'w ' . $orig_height . '->' . $new_height . 'h' . ' match: ' . $mtch[0], LOGGER_DEBUG);
|
||||
$s = str_replace($mtch[0],'[img=' . $new_width . 'x' . $new_height. ']' . $scaled . '[/img]'
|
||||
. "\n" . (($include_link)
|
||||
. "\n" . (($include_link)
|
||||
? '[url=' . $mtch[1] . ']' . t('view full size') . '[/url]' . "\n"
|
||||
: ''),$s);
|
||||
logger('scale_external_images: new string: ' . $s, LOGGER_DEBUG);
|
||||
|
@ -928,8 +931,8 @@ function fix_contact_ssl_policy(&$contact,$new_policy) {
|
|||
}
|
||||
|
||||
if($ssl_changed) {
|
||||
q("update contact set
|
||||
url = '%s',
|
||||
q("update contact set
|
||||
url = '%s',
|
||||
request = '%s',
|
||||
notify = '%s',
|
||||
poll = '%s',
|
||||
|
@ -984,7 +987,7 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority =
|
|||
return array();
|
||||
}
|
||||
|
||||
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
|
||||
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
|
||||
// http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
|
||||
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
|
||||
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
|
||||
|
@ -1114,6 +1117,8 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority =
|
|||
|
||||
function original_url($url, $depth=1, $fetchbody = false) {
|
||||
|
||||
$a = get_app();
|
||||
|
||||
// Remove Analytics Data from Google and other tracking platforms
|
||||
$urldata = parse_url($url);
|
||||
if (is_string($urldata["query"])) {
|
||||
|
@ -1163,7 +1168,7 @@ function original_url($url, $depth=1, $fetchbody = false) {
|
|||
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION."-".DB_UPDATE_VERSION.")");
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, $a->get_useragent());
|
||||
|
||||
$header = curl_exec($ch);
|
||||
$curl_info = @curl_getinfo($ch);
|
||||
|
|
|
@ -79,10 +79,13 @@ function advanced_profile(&$a) {
|
|||
if($txt = prepare_text($a->profile['work'])) $profile['work'] = array( t('Work/employment:'), $txt);
|
||||
|
||||
if($txt = prepare_text($a->profile['education'])) $profile['education'] = array( t('School/education:'), $txt );
|
||||
|
||||
|
||||
if ($a->profile['uid'] == local_user())
|
||||
$profile['edit'] = array($a->get_baseurl(). '/profiles/'.$a->profile['id'], t('Edit profile'),"", t('Edit profile'));
|
||||
|
||||
return replace_macros($tpl, array(
|
||||
'$title' => t('Profile'),
|
||||
'$profile' => $profile,
|
||||
'$title' => t('Profile'),
|
||||
'$profile' => $profile
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ function create_tags_from_item($itemid) {
|
|||
if ($message["deleted"])
|
||||
return;
|
||||
|
||||
$cachefile = get_cachefile($message["guid"]."-".hash("md5", $message['body']));
|
||||
$cachefile = get_cachefile(urlencode($message["guid"])."-".hash("md5", $message['body']));
|
||||
|
||||
if (($cachefile != '') AND !file_exists($cachefile)) {
|
||||
$s = prepare_text($message['body']);
|
||||
|
|
|
@ -1330,8 +1330,7 @@ function prepare_body(&$item,$attach = false, $preview = false) {
|
|||
$item['mentions'] = $mentions;
|
||||
|
||||
|
||||
//$cachefile = get_cachefile($item["guid"]."-".strtotime($item["edited"])."-".hash("crc32", $item['body']));
|
||||
$cachefile = get_cachefile($item["guid"]."-".hash("md5", $item['body']));
|
||||
$cachefile = get_cachefile(urlencode($item["guid"])."-".hash("md5", $item['body']));
|
||||
|
||||
if (($cachefile != '')) {
|
||||
if (file_exists($cachefile)) {
|
||||
|
@ -1503,7 +1502,7 @@ function prepare_text($text) {
|
|||
else
|
||||
$s = smilies(bbcode($text));
|
||||
|
||||
return $s;
|
||||
return trim($s);
|
||||
}}
|
||||
|
||||
|
||||
|
@ -2229,3 +2228,22 @@ function is_a_date_arg($s) {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* remove intentation from a text
|
||||
*/
|
||||
function deindent($text, $chr="[\t ]", $count=NULL) {
|
||||
$text = fix_mce_lf($text);
|
||||
$lines = explode("\n", $text);
|
||||
if (is_null($count)) {
|
||||
$m = array();
|
||||
$k=0; while($k<count($lines) && strlen($lines[$k])==0) $k++;
|
||||
preg_match("|^".$chr."*|", $lines[$k], $m);
|
||||
$count = strlen($m[0]);
|
||||
}
|
||||
for ($k=0; $k<count($lines); $k++){
|
||||
$lines[$k] = preg_replace("|^".$chr."{".$count."}|", "", $lines[$k]);
|
||||
}
|
||||
|
||||
return implode("\n", $lines);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ function last_error() {
|
|||
|
||||
/**
|
||||
* Remove columns from array $arr that aren't in table $table
|
||||
*
|
||||
*
|
||||
* @param string $table Table name
|
||||
* @param array &$arr Column=>Value array from json (by ref)
|
||||
*/
|
||||
|
@ -51,7 +51,7 @@ function check_cols($table, &$arr) {
|
|||
|
||||
/**
|
||||
* Import data into table $table
|
||||
*
|
||||
*
|
||||
* @param string $table Table name
|
||||
* @param array $arr Column=>Value array from json
|
||||
*/
|
||||
|
@ -162,7 +162,7 @@ function import_account(&$a, $file) {
|
|||
foreach ($profile as $k => &$v) {
|
||||
$v = str_replace($oldbaseurl, $newbaseurl, $v);
|
||||
foreach (array("profile", "avatar") as $k)
|
||||
$v = str_replace($newbaseurl . "/photo/" . $k . "/" . $olduid . ".jpg", $newbaseurl . "/photo/" . $k . "/" . $newuid . ".jpg", $v);
|
||||
$v = str_replace($oldbaseurl . "/photo/" . $k . "/" . $olduid . ".jpg", $newbaseurl . "/photo/" . $k . "/" . $newuid . ".jpg", $v);
|
||||
}
|
||||
$profile['uid'] = $newuid;
|
||||
$r = db_import_assoc('profile', $profile);
|
||||
|
@ -180,14 +180,14 @@ function import_account(&$a, $file) {
|
|||
foreach ($contact as $k => &$v) {
|
||||
$v = str_replace($oldbaseurl, $newbaseurl, $v);
|
||||
foreach (array("profile", "avatar", "micro") as $k)
|
||||
$v = str_replace($newbaseurl . "/photo/" . $k . "/" . $olduid . ".jpg", $newbaseurl . "/photo/" . $k . "/" . $newuid . ".jpg", $v);
|
||||
$v = str_replace($oldbaseurl . "/photo/" . $k . "/" . $olduid . ".jpg", $newbaseurl . "/photo/" . $k . "/" . $newuid . ".jpg", $v);
|
||||
}
|
||||
}
|
||||
if ($contact['uid'] == $olduid && $contact['self'] == '0') {
|
||||
// set contacts 'avatar-date' to "0000-00-00 00:00:00" to let poller to update urls
|
||||
$contact["avatar-date"] = "0000-00-00 00:00:00" ;
|
||||
|
||||
|
||||
|
||||
|
||||
switch ($contact['network']) {
|
||||
case NETWORK_DFRN:
|
||||
// send relocate message (below)
|
||||
|
|
|
@ -6,6 +6,7 @@ require_once('include/plugin.php');
|
|||
require_once('include/text.php');
|
||||
require_once('include/pgettext.php');
|
||||
require_once('include/datetime.php');
|
||||
require_once('include/enotify.php');
|
||||
|
||||
|
||||
function create_user($arr) {
|
||||
|
@ -44,7 +45,7 @@ function create_user($arr) {
|
|||
$result['message'] .= t('Invitation could not be verified.') . EOL;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if((! x($username)) || (! x($email)) || (! x($nickname))) {
|
||||
if($openid_url) {
|
||||
|
@ -57,17 +58,17 @@ function create_user($arr) {
|
|||
require_once('library/openid.php');
|
||||
$openid = new LightOpenID;
|
||||
$openid->identity = $openid_url;
|
||||
$openid->returnUrl = $a->get_baseurl() . '/openid';
|
||||
$openid->returnUrl = $a->get_baseurl() . '/openid';
|
||||
$openid->required = array('namePerson/friendly', 'contact/email', 'namePerson');
|
||||
$openid->optional = array('namePerson/first','media/image/aspect11','media/image/default');
|
||||
try {
|
||||
try {
|
||||
$authurl = $openid->authUrl();
|
||||
} catch (Exception $e){
|
||||
$result['message'] .= t("We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID."). EOL . EOL . t("The error message was:") . $e->getMessage() . EOL;
|
||||
$result['message'] .= t("We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID."). EOL . EOL . t("The error message was:") . $e->getMessage() . EOL;
|
||||
return $result;
|
||||
}
|
||||
goaway($authurl);
|
||||
// NOTREACHED
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
notice( t('Please enter the required information.') . EOL );
|
||||
|
@ -90,12 +91,12 @@ function create_user($arr) {
|
|||
|
||||
// I don't really like having this rule, but it cuts down
|
||||
// on the number of auto-registrations by Russian spammers
|
||||
|
||||
|
||||
// Using preg_match was completely unreliable, due to mixed UTF-8 regex support
|
||||
// $no_utf = get_config('system','no_utf');
|
||||
// $pat = (($no_utf) ? '/^[a-zA-Z]* [a-zA-Z]*$/' : '/^\p{L}* \p{L}*$/u' );
|
||||
// $pat = (($no_utf) ? '/^[a-zA-Z]* [a-zA-Z]*$/' : '/^\p{L}* \p{L}*$/u' );
|
||||
|
||||
// So now we are just looking for a space in the full name.
|
||||
// So now we are just looking for a space in the full name.
|
||||
|
||||
$loose_reg = get_config('system','no_regfullname');
|
||||
if(! $loose_reg) {
|
||||
|
@ -182,14 +183,14 @@ function create_user($arr) {
|
|||
* will take several minutes each to process.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
$sres = new_keypair(512);
|
||||
$sprvkey = $sres['prvkey'];
|
||||
$spubkey = $sres['pubkey'];
|
||||
|
||||
$r = q("INSERT INTO `user` ( `guid`, `username`, `password`, `email`, `openid`, `nickname`,
|
||||
`pubkey`, `prvkey`, `spubkey`, `sprvkey`, `register_date`, `verified`, `blocked`, `timezone`, `service_class` )
|
||||
VALUES ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, 'UTC', '%s' )",
|
||||
`pubkey`, `prvkey`, `spubkey`, `sprvkey`, `register_date`, `verified`, `blocked`, `timezone`, `service_class`, `default-location` )
|
||||
VALUES ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, 'UTC', '%s', '' )",
|
||||
dbesc(generate_user_guid()),
|
||||
dbesc($username),
|
||||
dbesc($new_password_encoded),
|
||||
|
@ -207,7 +208,7 @@ function create_user($arr) {
|
|||
);
|
||||
|
||||
if($r) {
|
||||
$r = q("SELECT * FROM `user`
|
||||
$r = q("SELECT * FROM `user`
|
||||
WHERE `username` = '%s' AND `password` = '%s' LIMIT 1",
|
||||
dbesc($username),
|
||||
dbesc($new_password_encoded)
|
||||
|
@ -220,10 +221,10 @@ function create_user($arr) {
|
|||
else {
|
||||
$result['message'] .= t('An error occurred during registration. Please try again.') . EOL ;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* if somebody clicked submit twice very quickly, they could end up with two accounts
|
||||
* if somebody clicked submit twice very quickly, they could end up with two accounts
|
||||
* due to race condition. Remove this one.
|
||||
*/
|
||||
|
||||
|
@ -281,8 +282,8 @@ function create_user($arr) {
|
|||
dbesc(datetime_convert())
|
||||
);
|
||||
|
||||
// Create a group with no members. This allows somebody to use it
|
||||
// right away as a default group for new contacts.
|
||||
// Create a group with no members. This allows somebody to use it
|
||||
// right away as a default group for new contacts.
|
||||
|
||||
require_once('include/group.php');
|
||||
group_add($newuid, t('Friends'));
|
||||
|
@ -323,7 +324,7 @@ function create_user($arr) {
|
|||
// guess mimetype from headers or filename
|
||||
$type = guess_image_type($photo,true);
|
||||
|
||||
|
||||
|
||||
$img = new Photo($img_str, $type);
|
||||
if($img->is_valid()) {
|
||||
|
||||
|
@ -365,3 +366,51 @@ function create_user($arr) {
|
|||
return $result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* send registration confirmation.
|
||||
* It's here as a function because the mail is sent
|
||||
* from different parts
|
||||
*/
|
||||
function send_register_open_eml($email, $sitename, $siteurl, $username, $password){
|
||||
$preamble = deindent(t('
|
||||
Dear %1$s,
|
||||
Thank you for registering at %2$s. Your account has been created.
|
||||
'));
|
||||
$body = deindent(t('
|
||||
The login details are as follows:
|
||||
Site Location: %3$s
|
||||
Login Name: %1$s
|
||||
Password: %5$s
|
||||
|
||||
You may change your password from your account "Settings" page after logging
|
||||
in.
|
||||
|
||||
Please take a few moments to review the other account settings on that page.
|
||||
|
||||
You may also wish to add some basic information to your default profile
|
||||
(on the "Profiles" page) so that other people can easily find you.
|
||||
|
||||
We recommend setting your full name, adding a profile photo,
|
||||
adding some profile "keywords" (very useful in making new friends) - and
|
||||
perhaps what country you live in; if you do not wish to be more specific
|
||||
than that.
|
||||
|
||||
We fully respect your right to privacy, and none of these items are necessary.
|
||||
If you are new and do not know anybody here, they may help
|
||||
you to make some new and interesting friends.
|
||||
|
||||
|
||||
Thank you and welcome to %2$s.'));
|
||||
|
||||
$preamble = sprintf($preamble, $username, $sitename);
|
||||
$body = sprintf($body, $email, $sitename, $siteurl, $username, $password);
|
||||
|
||||
return notification(array(
|
||||
'type' => "SYSTEM_EMAIL",
|
||||
'to_email' => $email,
|
||||
'subject'=> sprintf( t('Registration details for %s'), $sitename),
|
||||
'preamble'=> $preamble,
|
||||
'body' => $body));
|
||||
}
|
||||
|
|
33
index.php
33
index.php
|
@ -53,6 +53,13 @@ if(!$install) {
|
|||
load_config('config');
|
||||
load_config('system');
|
||||
|
||||
if (get_config('system','force_ssl') AND ($a->get_scheme() == "http") AND
|
||||
(intval(get_config('system','ssl_policy')) == SSL_POLICY_FULL) AND
|
||||
(substr($a->get_baseurl(), 0, 8) == "https://")) {
|
||||
header("HTTP/1.1 302 Moved Temporarily");
|
||||
header("location: ".$a->get_baseurl()."/".$a->query_string);
|
||||
}
|
||||
|
||||
require_once("include/session.php");
|
||||
load_hooks();
|
||||
call_hooks('init_1');
|
||||
|
@ -70,7 +77,7 @@ load_translation_table($lang);
|
|||
*
|
||||
* The order of these may be important so use caution if you think they're all
|
||||
* intertwingled with no logical order and decide to sort it out. Some of the
|
||||
* dependencies have changed, but at least at one time in the recent past - the
|
||||
* dependencies have changed, but at least at one time in the recent past - the
|
||||
* order was critical to everything working properly
|
||||
*
|
||||
*/
|
||||
|
@ -103,7 +110,7 @@ if((x($_GET,'zrl')) && (!$install && !$maintenance)) {
|
|||
*
|
||||
* For Mozilla auth manager - still needs sorting, and this might conflict with LRDD header.
|
||||
* Apache/PHP lumps the Link: headers into one - and other services might not be able to parse it
|
||||
* this way. There's a PHP flag to link the headers because by default this will over-write any other
|
||||
* this way. There's a PHP flag to link the headers because by default this will over-write any other
|
||||
* link header.
|
||||
*
|
||||
* What we really need to do is output the raw headers ourselves so we can keep them separate.
|
||||
|
@ -131,14 +138,16 @@ if(! x($_SESSION,'sysmsg_info'))
|
|||
$_SESSION['sysmsg_info'] = array();
|
||||
|
||||
/*
|
||||
* check_config() is responsible for running update scripts. These automatically
|
||||
* check_config() is responsible for running update scripts. These automatically
|
||||
* update the DB schema whenever we push a new one out. It also checks to see if
|
||||
* any plugins have been added or removed and reacts accordingly.
|
||||
* any plugins have been added or removed and reacts accordingly.
|
||||
*/
|
||||
|
||||
if($install)
|
||||
// in install mode, any url loads install module
|
||||
// but we need "view" module for stylesheet
|
||||
if($install && $a->module!="view")
|
||||
$a->module = 'install';
|
||||
elseif($maintenance)
|
||||
elseif($maintenance && $a->module!="view")
|
||||
$a->module = 'maintenance';
|
||||
else {
|
||||
check_url($a);
|
||||
|
@ -167,13 +176,13 @@ if((local_user()) || (! $privateapps === "1"))
|
|||
* and use it for handling our URL request.
|
||||
* The module file contains a few functions that we call in various circumstances
|
||||
* and in the following order:
|
||||
*
|
||||
*
|
||||
* "module"_init
|
||||
* "module"_post (only called if there are $_POST variables)
|
||||
* "module"_afterpost
|
||||
* "module"_content - the string return of this function contains our page body
|
||||
*
|
||||
* Modules which emit other serialisations besides HTML (XML,JSON, etc.) should do
|
||||
* Modules which emit other serialisations besides HTML (XML,JSON, etc.) should do
|
||||
* so within the module init and/or post functions and then invoke killme() to terminate
|
||||
* further processing.
|
||||
*/
|
||||
|
@ -222,8 +231,8 @@ if(strlen($a->module)) {
|
|||
*
|
||||
* The URL provided does not resolve to a valid module.
|
||||
*
|
||||
* On Dreamhost sites, quite often things go wrong for no apparent reason and they send us to '/internal_error.html'.
|
||||
* We don't like doing this, but as it occasionally accounts for 10-20% or more of all site traffic -
|
||||
* On Dreamhost sites, quite often things go wrong for no apparent reason and they send us to '/internal_error.html'.
|
||||
* We don't like doing this, but as it occasionally accounts for 10-20% or more of all site traffic -
|
||||
* we are going to trap this and redirect back to the requested page. As long as you don't have a critical error on your page
|
||||
* this will often succeed and eventually do the right thing.
|
||||
*
|
||||
|
@ -365,7 +374,7 @@ if(stristr( implode("",$_SESSION['sysmsg']), t('Permission denied'))) {
|
|||
* Report anything which needs to be communicated in the notification area (before the main body)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*if(x($_SESSION,'sysmsg')) {
|
||||
$a->page['content'] = "<div id=\"sysmsg\" class=\"error-message\">{$_SESSION['sysmsg']}</div>\r\n"
|
||||
. ((x($a->page,'content')) ? $a->page['content'] : '');
|
||||
|
@ -534,7 +543,7 @@ if (isset($_GET["mode"]) AND ($_GET["mode"] == "minimal")) {
|
|||
|
||||
require "view/minimal.php";
|
||||
} else {
|
||||
$template = 'view/theme/' . current_theme() . '/'
|
||||
$template = 'view/theme/' . current_theme() . '/'
|
||||
. ((x($a->page,'template')) ? $a->page['template'] : 'default' ) . '.php';
|
||||
|
||||
if(file_exists($template))
|
||||
|
|
|
@ -22,8 +22,8 @@ function ACL(backend_url, preset, automention){
|
|||
|
||||
/*events*/
|
||||
that.showall.click(that.on_showall);
|
||||
$(".acl-button-show").live('click', that.on_button_show);
|
||||
$(".acl-button-hide").live('click', that.on_button_hide);
|
||||
$(document).on("click", ".acl-button-show", that.on_button_show);
|
||||
$(document).on("click", ".acl-button-hide", that.on_button_hide);
|
||||
$("#acl-search").keypress(that.on_search);
|
||||
$("#acl-wrapper").parents("form").submit(that.on_submit);
|
||||
|
||||
|
|
1
js/acl.min.js
vendored
1
js/acl.min.js
vendored
File diff suppressed because one or more lines are too long
41
js/ajaxupload.min.js
vendored
41
js/ajaxupload.min.js
vendored
|
@ -1,41 +0,0 @@
|
|||
|
||||
(function(){function log(){if(typeof(console)!='undefined'&&typeof(console.log)=='function'){Array.prototype.unshift.call(arguments,'[Ajax Upload]');console.log(Array.prototype.join.call(arguments,' '));}}
|
||||
function addEvent(el,type,fn){if(el.addEventListener){el.addEventListener(type,fn,false);}else if(el.attachEvent){el.attachEvent('on'+type,function(){fn.call(el);});}else{throw new Error('not supported or DOM not loaded');}}
|
||||
function addResizeEvent(fn){var timeout;addEvent(window,'resize',function(){if(timeout){clearTimeout(timeout);}
|
||||
timeout=setTimeout(fn,100);});}
|
||||
var getOffsetSlow=function(el){var top=0,left=0;do{top+=el.offsetTop||0;left+=el.offsetLeft||0;el=el.offsetParent;}while(el);return{left:left,top:top};};if(document.documentElement.getBoundingClientRect){var getOffset=function(el){var box=el.getBoundingClientRect();var doc=el.ownerDocument;var body=doc.body;var docElem=doc.documentElement;var clientTop=docElem.clientTop||body.clientTop||0;var clientLeft=docElem.clientLeft||body.clientLeft||0;var zoom=1;if(body.getBoundingClientRect){var bound=body.getBoundingClientRect();zoom=(bound.right-bound.left)/body.clientWidth;}
|
||||
if(zoom==0||body.clientWidth==0)
|
||||
return getOffsetSlow(el);if(zoom>1){clientTop=0;clientLeft=0;}
|
||||
var top=box.top/zoom+(window.pageYOffset||docElem&&docElem.scrollTop/zoom||body.scrollTop/zoom)-clientTop,left=box.left/zoom+(window.pageXOffset||docElem&&docElem.scrollLeft/zoom||body.scrollLeft/zoom)-clientLeft;return{top:top,left:left};};}else{var getOffset=getOffsetSlow;}
|
||||
function getBox(el){var left,right,top,bottom;var offset=getOffset(el);left=offset.left;top=offset.top;right=left+el.offsetWidth;bottom=top+el.offsetHeight;return{left:left,right:right,top:top,bottom:bottom};}
|
||||
function addStyles(el,styles){for(var name in styles){if(styles.hasOwnProperty(name)){el.style[name]=styles[name];}}}
|
||||
function copyLayout(from,to){var box=getBox(from);addStyles(to,{position:'absolute',left:box.left+'px',top:box.top+'px',width:from.offsetWidth+'px',height:from.offsetHeight+'px'});to.title=from.title;}
|
||||
var toElement=(function(){var div=document.createElement('div');return function(html){div.innerHTML=html;var el=div.firstChild;return div.removeChild(el);};})();var getUID=(function(){var id=0;return function(){return'ValumsAjaxUpload'+id++;};})();function fileFromPath(file){return file.replace(/.*(\/|\\)/,"");}
|
||||
function getExt(file){return(-1!==file.indexOf('.'))?file.replace(/.*[.]/,''):'';}
|
||||
function hasClass(el,name){var re=new RegExp('\\b'+name+'\\b');return re.test(el.className);}
|
||||
function addClass(el,name){if(!hasClass(el,name)){el.className+=' '+name;}}
|
||||
function removeClass(el,name){var re=new RegExp('\\b'+name+'\\b');el.className=el.className.replace(re,'');}
|
||||
function removeNode(el){el.parentNode.removeChild(el);}
|
||||
window.AjaxUpload=function(button,options){this._settings={action:'upload.php',name:'userfile',data:{},autoSubmit:true,responseType:false,hoverClass:'hover',focusClass:'focus',disabledClass:'disabled',onChange:function(file,extension){},onSubmit:function(file,extension){},onComplete:function(file,response){}};for(var i in options){if(options.hasOwnProperty(i)){this._settings[i]=options[i];}}
|
||||
if(button.jquery){button=button[0];}else if(typeof button=="string"){if(/^#.*/.test(button)){button=button.slice(1);}
|
||||
button=document.getElementById(button);}
|
||||
if(!button||button.nodeType!==1){throw new Error("Please make sure that you're passing a valid element");}
|
||||
if(button.nodeName.toUpperCase()=='A'){addEvent(button,'click',function(e){if(e&&e.preventDefault){e.preventDefault();}else if(window.event){window.event.returnValue=false;}});}
|
||||
this._button=button;this._input=null;this._disabled=false;this.enable();this._rerouteClicks();};AjaxUpload.prototype={setData:function(data){this._settings.data=data;},disable:function(){addClass(this._button,this._settings.disabledClass);this._disabled=true;var nodeName=this._button.nodeName.toUpperCase();if(nodeName=='INPUT'||nodeName=='BUTTON'){this._button.setAttribute('disabled','disabled');}
|
||||
if(this._input){this._input.parentNode.style.visibility='hidden';}},enable:function(){removeClass(this._button,this._settings.disabledClass);this._button.removeAttribute('disabled');this._disabled=false;},_createInput:function(){var self=this;var input=document.createElement("input");input.setAttribute('type','file');input.setAttribute('name',this._settings.name);addStyles(input,{'position':'absolute','right':0,'margin':0,'padding':0,'fontSize':'480px','fontFamily':'sans-serif','cursor':'pointer'});var div=document.createElement("div");addStyles(div,{'display':'block','position':'absolute','overflow':'hidden','margin':0,'padding':0,'opacity':0,'direction':'ltr','zIndex':2147483583,'cursor':'pointer'});if(div.style.opacity!=="0"){if(typeof(div.filters)=='undefined'){throw new Error('Opacity not supported by the browser');}
|
||||
div.style.filter="alpha(opacity=0)";}
|
||||
addEvent(input,'change',function(){if(!input||input.value===''){return;}
|
||||
var file=fileFromPath(input.value);if(false===self._settings.onChange.call(self,file,getExt(file))){self._clearInput();return;}
|
||||
if(self._settings.autoSubmit){self.submit();}});addEvent(input,'mouseover',function(){addClass(self._button,self._settings.hoverClass);});addEvent(input,'mouseout',function(){removeClass(self._button,self._settings.hoverClass);removeClass(self._button,self._settings.focusClass);input.parentNode.style.visibility='hidden';});addEvent(input,'focus',function(){addClass(self._button,self._settings.focusClass);});addEvent(input,'blur',function(){removeClass(self._button,self._settings.focusClass);});div.appendChild(input);document.body.appendChild(div);this._input=input;},_clearInput:function(){if(!this._input){return;}
|
||||
removeNode(this._input.parentNode);this._input=null;this._createInput();removeClass(this._button,this._settings.hoverClass);removeClass(this._button,this._settings.focusClass);},_rerouteClicks:function(){var self=this;addEvent(self._button,'mouseover',function(){if(self._disabled){return;}
|
||||
if(!self._input){self._createInput();}
|
||||
var div=self._input.parentNode;copyLayout(self._button,div);div.style.visibility='visible';});},_createIframe:function(){var id=getUID();var iframe=toElement('<iframe src="javascript:false;" name="'+id+'" />');iframe.setAttribute('id',id);iframe.style.display='none';document.body.appendChild(iframe);return iframe;},_createForm:function(iframe){var settings=this._settings;var form=toElement('<form method="post" enctype="multipart/form-data"></form>');form.setAttribute('action',settings.action);form.setAttribute('target',iframe.name);form.style.display='none';document.body.appendChild(form);for(var prop in settings.data){if(settings.data.hasOwnProperty(prop)){var el=document.createElement("input");el.setAttribute('type','hidden');el.setAttribute('name',prop);el.setAttribute('value',settings.data[prop]);form.appendChild(el);}}
|
||||
return form;},_getResponse:function(iframe,file){var toDeleteFlag=false,self=this,settings=this._settings;addEvent(iframe,'load',function(){if(iframe.src=="javascript:'%3Chtml%3E%3C/html%3E';"||iframe.src=="javascript:'<html></html>';"){if(toDeleteFlag){setTimeout(function(){removeNode(iframe);},0);}
|
||||
return;}
|
||||
var doc=iframe.contentDocument?iframe.contentDocument:window.frames[iframe.id].document;if(doc.readyState&&doc.readyState!='complete'){return;}
|
||||
if(doc.body&&doc.body.innerHTML=="false"){return;}
|
||||
var response;if(doc.XMLDocument){response=doc.XMLDocument;}else if(doc.body){response=doc.body.innerHTML;if(settings.responseType&&settings.responseType.toLowerCase()=='json'){if(doc.body.firstChild&&doc.body.firstChild.nodeName.toUpperCase()=='PRE'){doc.normalize();response=doc.body.firstChild.firstChild.nodeValue;}
|
||||
if(response){response=eval("("+response+")");}else{response={};}}}else{response=doc;}
|
||||
settings.onComplete.call(self,file,response);toDeleteFlag=true;iframe.src="javascript:'<html></html>';";});},submit:function(){var self=this,settings=this._settings;if(!this._input||this._input.value===''){return;}
|
||||
var file=fileFromPath(this._input.value);if(false===settings.onSubmit.call(this,file,getExt(file))){this._clearInput();return;}
|
||||
var iframe=this._createIframe();var form=this._createForm(iframe);removeNode(this._input.parentNode);removeClass(self._button,self._settings.hoverClass);removeClass(self._button,self._settings.focusClass);form.appendChild(this._input);form.submit();removeNode(form);form=null;removeNode(this._input);this._input=null;this._getResponse(iframe,file);this._createInput();}};})();
|
2
js/country.min.js
vendored
2
js/country.min.js
vendored
File diff suppressed because one or more lines are too long
1
js/fk.autocomplete.min.js
vendored
1
js/fk.autocomplete.min.js
vendored
|
@ -1 +0,0 @@
|
|||
function ACPopup(elm,backend_url){this.idsel=-1;this.element=elm;this.searchText="";this.ready=true;this.kp_timer=false;this.url=backend_url;var w=530;var h=130;if(typeof elm.editorId=="undefined"){style=$(elm).offset();w=$(elm).width();h=$(elm).height()}else{var container=elm.getContainer();if(typeof container!="undefined"){style=$(container).offset();w=$(container).width();h=$(container).height()}}style.top=style.top+h;style.width=w;style.position="absolute";style.display="none";this.cont=$("<div class='acpopup'></div>");this.cont.css(style);$("body").append(this.cont)}ACPopup.prototype.close=function(){$(this.cont).remove();this.ready=false};ACPopup.prototype.search=function(text){var that=this;this.searchText=text;if(this.kp_timer)clearTimeout(this.kp_timer);this.kp_timer=setTimeout(function(){that._search()},500)};ACPopup.prototype._search=function(){console.log("_search");var that=this;var postdata={start:0,count:100,search:this.searchText,type:"c"};$.ajax({type:"POST",url:this.url,data:postdata,dataType:"json",success:function(data){that.cont.html("");if(data.tot>0){that.cont.show();$(data.items).each(function(){html="<img src='{0}' height='16px' width='16px'>{1} ({2})".format(this.photo,this.name,this.nick);that.add(html,this.nick.replace(" ","")+"+"+this.id+" - "+this.link)})}else{that.cont.hide()}}})};ACPopup.prototype.add=function(label,value){var that=this;var elm=$("<div class='acpopupitem' title='"+value+"'>"+label+"</div>");elm.click(function(e){t=$(this).attr("title").replace(new RegExp(" - .*"),"");if(typeof that.element.container==="undefined"){el=$(that.element);sel=el.getSelection();sel.start=sel.start-that.searchText.length;el.setSelection(sel.start,sel.end).replaceSelectedText(t+" ").collapseSelection(false);that.close()}else{txt=tinyMCE.activeEditor.getContent();newtxt=txt.replace("@"+that.searchText,"@"+t+" ");tinyMCE.activeEditor.setContent(newtxt);tinyMCE.activeEditor.focus();that.close()}});$(this.cont).append(elm)};ACPopup.prototype.onkey=function(event){if(event.keyCode=="13"){if(this.idsel>-1){this.cont.children()[this.idsel].click();event.preventDefault()}else this.close()}if(event.keyCode=="38"){cmax=this.cont.children().size()-1;this.idsel--;if(this.idsel<0)this.idsel=cmax;event.preventDefault()}if(event.keyCode=="40"||event.keyCode=="9"){cmax=this.cont.children().size()-1;this.idsel++;if(this.idsel>cmax)this.idsel=0;event.preventDefault()}if(event.keyCode=="38"||event.keyCode=="40"||event.keyCode=="9"){this.cont.children().removeClass("selected");$(this.cont.children()[this.idsel]).addClass("selected")}if(event.keyCode=="27"){this.close()}};function ContactAutocomplete(element,backend_url){this.pattern=/@([^ \n]+)$/;this.popup=null;var that=this;$(element).unbind("keydown");$(element).unbind("keyup");$(element).keydown(function(event){if(that.popup!==null)that.popup.onkey(event)});$(element).keyup(function(event){cpos=$(this).getSelection();if(cpos.start==cpos.end){match=$(this).val().substring(0,cpos.start).match(that.pattern);if(match!==null){if(that.popup===null){that.popup=new ACPopup(this,backend_url)}if(that.popup.ready&&match[1]!==that.popup.searchText)that.popup.search(match[1]);if(!that.popup.ready)that.popup=null}else{if(that.popup!==null){that.popup.close();that.popup=null}}}})}(function($){$.fn.contact_autocomplete=function(backend_url){this.each(function(){new ContactAutocomplete(this,backend_url)})}})(jQuery);
|
2
js/jquery-migrate.js
vendored
Normal file
2
js/jquery-migrate.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
js/jquery.htmlstream.min.js
vendored
1
js/jquery.htmlstream.min.js
vendored
|
@ -1 +0,0 @@
|
|||
(function($){var ajax_old=$.ajax;var get_old=$.get;var post_old=$.post;var active=true;$.ajaxSetup({stream:false,pollInterval:500});$.enableAjaxStream=function(enable){if(typeof enable=="undefined")enable=!active;if(!enable){$.ajax=ajax_old;$.get=get_old;$.post=post_old;active=false}else{$.ajax=ajax_stream;$.get=ajax_get_stream;$.post=ajax_post_stream;active=true}};var ajax_stream=$.ajax=function(options){options=jQuery.extend(true,options,jQuery.extend(true,{},jQuery.ajaxSettings,options));if(options.stream){var timer=0;var offset=0;var xmlhttp=null;var lastlen=0;var done=false;var hook=function(xhr){xmlhttp=xhr;checkagain()};var fix=function(){check("stream")};var checkagain=function(){if(!done)timer=setTimeout(fix,options.pollInterval)};var check=function(status){if(typeof status=="undefined")status="stream";if(xmlhttp.status<3)return;var text=xmlhttp.responseText;if(status=="stream"){if(text.length<=lastlen){checkagain();return}lastlength=text.length;if(offset==text.length){checkagain();return}}var pkt=text.substr(offset);offset=text.length;if($.isFunction(options.OnDataRecieved)){options.OnDataRecieved(pkt,status,xmlhttp.responseText,xmlhttp)}if(xmlhttp.status!=4)checkagain()};var complete=function(xhr,s){clearTimeout(timer);done=true;check(s)};if($.isFunction(options.success)){var oc=options.success;options.success=function(xhr,s){complete(xhr,s);oc(xhr,s)}}else options.success=complete;if($.isFunction(options.beforeSend)){var obs=options.beforeSend;options.beforeSend=function(xhr){obs(xhr);hook(xhr)}}else options.beforeSend=hook}ajax_old(options)};var ajax_get_stream=$.get=function(url,data,callback,type,stream){if($.isFunction(data)){var orgcb=callback;callback=data;if($.isFunction(orgcb)){stream=orgcb}data=null}if($.isFunction(type)){stream=type;type=undefined}var dostream=$.isFunction(stream);return jQuery.ajax({type:"GET",url:url,data:data,success:callback,dataType:type,stream:dostream,OnDataRecieved:stream})};var ajax_post_stream=$.post=function(url,data,callback,type,stream){if($.isFunction(data)){var orgcb=callback;callback=data}if($.isFunction(type)){stream=type;type=undefined}var dostream=$.isFunction(stream);return jQuery.ajax({type:"POST",url:url,data:data,success:callback,dataType:type,stream:dostream,OnDataRecieved:stream})}})(jQuery);
|
8
js/jquery.js
vendored
8
js/jquery.js
vendored
File diff suppressed because one or more lines are too long
18
js/main.js
18
js/main.js
|
@ -22,7 +22,6 @@
|
|||
var prev = null;
|
||||
var livetime = null;
|
||||
var force_update = false;
|
||||
var msie = false;
|
||||
var stopped = false;
|
||||
var totStopped = false;
|
||||
var timer = null;
|
||||
|
@ -37,8 +36,6 @@
|
|||
$(function() {
|
||||
$.ajaxSetup({cache: false});
|
||||
|
||||
msie = $.browser.msie ;
|
||||
|
||||
/* setup tooltips *//*
|
||||
$("a,.tt").each(function(){
|
||||
var e = $(this);
|
||||
|
@ -83,19 +80,23 @@
|
|||
}
|
||||
}
|
||||
$('a[rel^=#]').click(function(e){
|
||||
e.preventDefault();
|
||||
var parent = $(this).parent();
|
||||
var isSelected = (last_popup_button && parent.attr('id') == last_popup_button.attr('id'));
|
||||
close_last_popup_menu();
|
||||
if(isSelected) return false;
|
||||
menu = $( $(this).attr('rel') );
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
if (menu.attr('popup')=="false") return false;
|
||||
$(this).parent().toggleClass("selected");
|
||||
parent.toggleClass("selected");
|
||||
menu.toggle();
|
||||
if (menu.css("display") == "none") {
|
||||
last_popup_menu = null;
|
||||
last_popup_button = null;
|
||||
} else {
|
||||
last_popup_menu = menu;
|
||||
last_popup_button = $(this).parent();
|
||||
last_popup_button = parent;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
@ -104,10 +105,6 @@
|
|||
});
|
||||
|
||||
// fancyboxes
|
||||
/*$("a.popupbox").fancybox({
|
||||
'transitionIn' : 'elastic',
|
||||
'transitionOut' : 'elastic'
|
||||
});*/
|
||||
$("a.popupbox").colorbox({
|
||||
'inline' : true,
|
||||
'transition' : 'elastic'
|
||||
|
@ -307,7 +304,7 @@
|
|||
force_update = true;
|
||||
|
||||
var udargs = ((netargs.length) ? '/' + netargs : '');
|
||||
var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&msie=' + ((msie) ? 1 : 0) + '&force=' + ((force_update) ? 1 : 0);
|
||||
var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&force=' + ((force_update) ? 1 : 0);
|
||||
|
||||
$.get(update_url,function(data) {
|
||||
in_progress = false;
|
||||
|
@ -706,6 +703,7 @@ function setupFieldRichtext(){
|
|||
theme_advanced_toolbar_location : "top",
|
||||
theme_advanced_toolbar_align : "center",
|
||||
theme_advanced_blockformats : "blockquote,code",
|
||||
theme_advanced_resizing : true,
|
||||
paste_text_sticky : true,
|
||||
entity_encoding : "raw",
|
||||
add_unload_trigger : false,
|
||||
|
|
1
js/main.min.js
vendored
1
js/main.min.js
vendored
File diff suppressed because one or more lines are too long
4
js/modernizr.js
Normal file
4
js/modernizr.js
Normal file
File diff suppressed because one or more lines are too long
1
js/webtoolkit.base64.min.js
vendored
1
js/webtoolkit.base64.min.js
vendored
|
@ -1 +0,0 @@
|
|||
var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(input){var output="";var chr1,chr2,chr3,enc1,enc2,enc3,enc4;var i=0;input=Base64._utf8_encode(input);while(i<input.length){chr1=input.charCodeAt(i++);chr2=input.charCodeAt(i++);chr3=input.charCodeAt(i++);enc1=chr1>>2;enc2=(chr1&3)<<4|chr2>>4;enc3=(chr2&15)<<2|chr3>>6;enc4=chr3&63;if(isNaN(chr2)){enc3=enc4=64}else if(isNaN(chr3)){enc4=64}output=output+this._keyStr.charAt(enc1)+this._keyStr.charAt(enc2)+this._keyStr.charAt(enc3)+this._keyStr.charAt(enc4)}return output},decode:function(input){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(i<input.length){enc1=this._keyStr.indexOf(input.charAt(i++));enc2=this._keyStr.indexOf(input.charAt(i++));enc3=this._keyStr.indexOf(input.charAt(i++));enc4=this._keyStr.indexOf(input.charAt(i++));chr1=enc1<<2|enc2>>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;output=output+String.fromCharCode(chr1);if(enc3!=64){output=output+String.fromCharCode(chr2)}if(enc4!=64){output=output+String.fromCharCode(chr3)}}output=Base64._utf8_decode(output);return output},_utf8_encode:function(string){string=string.replace(/\r\n/g,"\n");var utftext="";for(var n=0;n<string.length;n++){var c=string.charCodeAt(n);if(c<128){utftext+=String.fromCharCode(c)}else if(c>127&&c<2048){utftext+=String.fromCharCode(c>>6|192);utftext+=String.fromCharCode(c&63|128)}else{utftext+=String.fromCharCode(c>>12|224);utftext+=String.fromCharCode(c>>6&63|128);utftext+=String.fromCharCode(c&63|128)}}return utftext},_utf8_decode:function(utftext){var string="";var i=0;var c=c1=c2=0;while(i<utftext.length){c=utftext.charCodeAt(i);if(c<128){string+=String.fromCharCode(c);i++}else if(c>191&&c<224){c2=utftext.charCodeAt(i+1);string+=String.fromCharCode((c&31)<<6|c2&63);i+=2}else{c2=utftext.charCodeAt(i+1);c3=utftext.charCodeAt(i+2);string+=String.fromCharCode((c&15)<<12|(c2&63)<<6|c3&63);i+=3}}return string}};
|
|
@ -1,4 +1,4 @@
|
|||
Smarty 3.1.11
|
||||
Smarty 3.1.19
|
||||
|
||||
Author: Monte Ohrt <monte at ohrt dot com >
|
||||
Author: Uwe Tews
|
||||
|
@ -120,7 +120,7 @@ $smarty->unregisterObject($object_name)
|
|||
$smarty->unregisterFilter($type, $function_name)
|
||||
$smarty->unregisterResource($resource_type)
|
||||
|
||||
$smarty->compileAllTemplates($extention = '.tpl', $force_compile = false, $time_limit = 0, $max_errors = null)
|
||||
$smarty->compileAllTemplates($extension = '.tpl', $force_compile = false, $time_limit = 0, $max_errors = null)
|
||||
$smarty->clearCompiledTemplate($resource_name = null, $compile_id = null, $exp_time = null)
|
||||
$smarty->testInstall()
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ Relative paths are available with {include file="..."} and
|
|||
$smarty->fetch('./foo.tpl') cannot be relative to a template, an
|
||||
exception is thrown.
|
||||
|
||||
Adressing a specific $template_dir
|
||||
Addressing a specific $template_dir
|
||||
|
||||
Smarty 3.1 introduces the $template_dir index notation.
|
||||
$smarty->fetch('[foo]bar.tpl') and {include file="[foo]bar.tpl"}
|
||||
|
|
|
@ -1,5 +1,298 @@
|
|||
===== trunk =====
|
||||
===== Smarty-3.1.11 =====
|
||||
===== 3.1.20-dev ===== (xx.xx.2014)
|
||||
===== 3.1.19 ===== (06.30.2014)
|
||||
20.06.2014
|
||||
- bugfix template variables could not be passed as paramter in {include} when the include was in a {nocache} section (topic 25131)
|
||||
|
||||
17.06.2014
|
||||
- bugfix large template text of some charsets could cause parsing errors (topic 24630)
|
||||
|
||||
08.06.2014
|
||||
- bugfix registered objects did not work after spelling fixes of 06.06.2014
|
||||
- bugfix {block} tags within {literal} .. {/literal} got not displayed correctly (topic 25024)
|
||||
- bugfix UNC WINDOWS PATH like "\\psf\path\to\dir" did not work as template directory (Issue 192)
|
||||
- bugfix {html_image} security check did fail on files relative to basedir (Issue 191)
|
||||
|
||||
06.06.2014
|
||||
- fixed PHPUnit outputFilterTrimWhitespaceTests.php assertion of test result
|
||||
- fixed spelling, PHPDoc , minor errors, code cleanup
|
||||
|
||||
02.06.2014
|
||||
- using multiple cwd with relative template dirs could result in identical compiled file names. (issue 194 and topic 25099)
|
||||
|
||||
19.04.2014
|
||||
- bugfix calling createTemplate(template, data) with empty data array caused notice of array to string conversion (Issue 189)
|
||||
- bugfix clearCompiledTemplate() did not delete files on WINDOWS when a compile_id was specified
|
||||
|
||||
18.04.2014
|
||||
- revert bugfix of 5.4.2014 because %-e date format is not supported on all operating systems
|
||||
|
||||
===== 3.1.18 ===== (07.04.2014)
|
||||
06.04.2014
|
||||
- bugfix template inheritance fail when using custom resource after patch of 8.3.2014 (Issue 187)
|
||||
- bugfix update of composer file (Issue 168 and 184)
|
||||
|
||||
05.04.2014
|
||||
- bugfix default date format leads to extra spaces when displaying dates with single digit days (Issue 165)
|
||||
|
||||
26.03.2014
|
||||
- bugfix Smart_Resource_Custom should not lowercase the resource name (Issue 183)
|
||||
|
||||
24.03.2014
|
||||
- bugfix using a {foreach} property like @iteration could fail when used in inheritance parent templates (Issue 182)
|
||||
|
||||
20.03.2014
|
||||
- bugfix $smarty->auto_literal and mbsting.func_overload 2, 6 or 7 did fail (forum topic 24899)
|
||||
|
||||
18.03.2014
|
||||
- revert change of 17.03.2014
|
||||
|
||||
17.03.2014
|
||||
- bugfix $smarty->auto_literal and mbsting.func_overload 2, 6 or 7 did fail (forum topic 24899)
|
||||
|
||||
15.03.2014
|
||||
- bugfix Smarty_CacheResource_Keyvaluestore did use different keys on read/writes and clearCache() calls (Issue 169)
|
||||
|
||||
13.03.2014
|
||||
- bugfix clearXxx() change of 27.1.2014 did not work when specifing cache_id or compile_id (forum topic 24868 and 24867)
|
||||
|
||||
===== 3.1.17 =====
|
||||
08.03.2014
|
||||
- bugfix relative file path {include} within {block} of child templates did throw exception on first call (Issue 177)
|
||||
|
||||
17.02.2014
|
||||
- bugfix Smarty failed when executing PHP on HHVM (Hip Hop 2.4) because uniqid('',true) does return string with ',' (forum topic 20343)
|
||||
|
||||
16.02.2014
|
||||
- bugfix a '//' or '\\' in template_dir path could produce wrong path on relative filepath in {include} (Issue 175)
|
||||
|
||||
05.02.2014
|
||||
- bugfix shared.literal_compiler_param.php did throw an exception when literal did contain a '-' (smarty-developers group)
|
||||
|
||||
27.01.2014
|
||||
- bugfix $smarty->debugging = true; did show the variable of the $smarty object not the variables used in display() call (forum topic 24764)
|
||||
- bugfix clearCompiledTemplate(), clearAll() and clear() should use realpath to avoid possible exception from RecursiveDirectoryIterator (Issue 171)
|
||||
|
||||
26.01.2014
|
||||
- bugfix undo block nesting checks for {nocache} for reasons like forum topic 23280 (forum topic 24762)
|
||||
|
||||
18.01.2014
|
||||
- bugfix the compiler did fail when using template inheritance and recursive {include} (smarty-developers group)
|
||||
|
||||
11.01.2014
|
||||
- bugfix "* }" (spaces before right delimiter) was interpreted by mistake as comment end tag (Issue 170)
|
||||
- internals content cache should be clear when updating cache file
|
||||
|
||||
08.01.2014
|
||||
- bugfix Smarty_CacheResource_Custom did not handle template resource type specifications on clearCache() calls (Issue 169)
|
||||
- bugfix SmartyBC.class.php should use require_once to load Smarty.class.php (forum topic 24683)
|
||||
|
||||
===== 3.1.16 =====
|
||||
15.12.2013
|
||||
- bugfix {include} with {block} tag handling (forum topic 24599, 24594, 24682) (Issue 161)
|
||||
Read 3.1.16_RELEASE_NOTES for more details
|
||||
- enhancement additional debug output at $smarty->_parserdebug = true;
|
||||
|
||||
07.11.2013
|
||||
- bugfix too restrictive handling of {include} within {block} tags. 3.1.15 did throw errors where 3.1.14 did not (forum topic 24599)
|
||||
- bugfix compiler could fail if PHP mbstring.func_overload is enabled (Issue 164)
|
||||
|
||||
28.10.2013
|
||||
- bugfix variable resource name at custom resource plugin did not work within {block} tags (Issue 163)
|
||||
- bugfix notice "Trying to get property of non-object" removed (Issue 163)
|
||||
- bugfix correction of modifier capitalize fix from 3.10.2013 (issue 159)
|
||||
- bugfix multiple {block}s with same name in parent did not work (forum topic 24631)
|
||||
|
||||
20.10.2013
|
||||
- bugfix a variable file name at {extends} tag did fail (forum topic 24618)
|
||||
|
||||
14.10.2013
|
||||
- bugfix yesterdays fix could result in an undefined variable
|
||||
|
||||
13.10.2013
|
||||
- bugfix variable names on {include} in template inheritance did unextepted error message (forum topic 24594) (Issue 161)
|
||||
.- bugfix relative includes with same name like {include './foo.tpl'} from different folder failed (forum topic 24590)(Issue 161)
|
||||
|
||||
04.10.2013
|
||||
- bugfix variable file names at {extends} had been disbabled by mistake with the rewrite of
|
||||
template inheritance of 24.08.2013 (forum topic 24585)
|
||||
|
||||
03.10.2013
|
||||
- bugfix loops using modifier capitalize did eat up memory (issue 159)
|
||||
|
||||
===== Smarty 3.1.15 =====
|
||||
01.10.2013
|
||||
- use current delimiters in compiler error messages (issue 157)
|
||||
- improvement on performance when using error handler and multiple template folders (issue 152)
|
||||
|
||||
17.09.2013
|
||||
- improvement added patch for additional SmartyCompilerException properties for better access to scource information (forum topic 24559)
|
||||
|
||||
16.09.2013
|
||||
- bugfix recompiled templates did not show on first request with zend opcache cache (forum topic 24320)
|
||||
|
||||
13.09.2013
|
||||
- bugfix html_select_time defaulting error for the Meridian dropdown (forum topic 24549)
|
||||
|
||||
09.09.2012
|
||||
- bugfix incorrect compiled code with array(object,method) callback at registered Variable Filter (forum topic 24542)
|
||||
|
||||
27.08.2013
|
||||
- bugfix delimiter followed by linebreak did not work as auto literal after update from 24.08.2013 (forum topic 24518)
|
||||
|
||||
24.08.2013
|
||||
- bugfix and enhancement
|
||||
Because several recent problems with template inheritance the {block} tag compiler has been rewriten
|
||||
- Error messages shown now the correct child template file and line number
|
||||
- The compiler could fail on some larger UTF-8 text block (forum topic 24455)
|
||||
- The {strip} tag can now be placed outside {block} tags in child templates (forum topic 24289)
|
||||
- change SmartyException::$escape is now false by default
|
||||
- change PHP traceback has been remove for SmartyException and SmartyCompilerException
|
||||
|
||||
14.08.2013
|
||||
- bugfix compiled filepath of config file did not observe different config_dir (forum topic 24493)
|
||||
|
||||
13.08.2013
|
||||
- bugfix the internal resource cache did not observe config_dir changes (forum topic 24493)
|
||||
|
||||
12.08.2013
|
||||
- bugfix internal $tmpx variables must be unique over all inheritance templates (Issue 149)
|
||||
|
||||
10.08.2013
|
||||
- bugfix a newline was eaten when a <?xml ... ?> was passed by a Smarty variable and caching was enabled (forum topic 24482)
|
||||
|
||||
29.07.2013
|
||||
- bugfix headers already send warning thrown when using 'SMARTY_DEBUG=on' from URL (Issue 148)
|
||||
|
||||
27.07.2013
|
||||
- enhancement allow access to properties of registered opjects for Smarty2 BC (forum topic 24344)
|
||||
|
||||
26.07.2013
|
||||
- bugfix template inheritance nesting problem (forum topic 24387)
|
||||
|
||||
15.7.2013
|
||||
- update code generated by PSR-2 standards fixer which introduced PHP 5.4 incompatibilities of 14.7.2013
|
||||
|
||||
14.7.2013
|
||||
- bugfix increase of internal maximum parser stacksize to allow more complex tag code {forum topic 24426}
|
||||
- update for PHP 5.4 compatibility
|
||||
- reformat source to PSR-2 standard
|
||||
|
||||
12.7.2013
|
||||
- bugfix Do not remove '//' from file path at normalization (Issue 142)
|
||||
|
||||
2.7.2013
|
||||
- bugfix trimwhitespace would replace captured items in wrong order (forum topic 24387)
|
||||
|
||||
===== Smarty-3.1.14 =====
|
||||
27.06.2013
|
||||
- bugfix removed PHP 5.5 deprecated preg_replace /e option in modifier capitalize (forum topic 24389)
|
||||
|
||||
17.06.2013
|
||||
- fixed spelling in sources and documentation (from smarty-developers forum Veres Lajos)
|
||||
- enhancement added constant SMARTY::CLEAR_EXPIRED for the change of 26.05.2013 (forum topic 24310)
|
||||
- bugfix added smarty_security.php to composer.json (Issue 135)
|
||||
|
||||
26.05.2013
|
||||
- enhancement an expire_time of -1 in clearCache() and clearAllCache() will delete outdated cache files
|
||||
by their individual cache_lifetime used at creation (forum topic 24310)
|
||||
|
||||
21.05.2013
|
||||
- bugfix modifier strip_tags:true was compiled into wrong code (Forum Topic 24287)
|
||||
- bugfix /n after ?> in Smarty.class.php did start output buffering (Issue 138)
|
||||
|
||||
25.04.2013
|
||||
- bugfix escape and wordrap modifier could be compiled into wrong code when used in {nocache}{/nocache}
|
||||
section but caching is disabled (Forum Topic 24260)
|
||||
|
||||
05.04.2013
|
||||
- bugfix post filter must not run when compiling inheritance child blocks (Forum Topic 24094)
|
||||
- bugfix after the fix for Issue #130 compiler exceptions got double escaped (Forum Topic 24199)
|
||||
|
||||
28.02.2013
|
||||
- bugfix nocache blocks could be lost when using CACHING_LIFETIME_SAVED (Issue #133)
|
||||
- bugfix Compile ID gets nulled when compiling child blocks (Issue #134)
|
||||
|
||||
|
||||
24.01.2013
|
||||
- bugfix wrong tag type in smarty_internal_templatecompilerbase.php could cause wrong plugin search order (Forum Topic 24028)
|
||||
|
||||
===== Smarty-3.1.13 =====
|
||||
13.01.2013
|
||||
- enhancement allow to disable exception message escaping by SmartyException::$escape = false; (Issue #130)
|
||||
|
||||
09.01.2013
|
||||
- bugfix compilation did fail when a prefilter did modify an {extends} tag c
|
||||
- bugfix template inheritance could fail if nested {block} tags in childs did contain {$smarty.block.child} (Issue #127)
|
||||
- bugfix template inheritance could fail if {block} tags in childs did have similar name as used plugins (Issue #128)
|
||||
- added abstract method declaration doCompile() in Smarty_Internal_TemplateCompilerBase (Forum Topic 23969)
|
||||
|
||||
06.01.2013
|
||||
- Allow '://' URL syntax in template names of stream resources (Issue #129)
|
||||
|
||||
27.11.2012
|
||||
- bugfix wrong variable usage in smarty_internal_utility.php (Issue #125)
|
||||
|
||||
26.11.2012
|
||||
- bugfix global variable assigned within template function are not seen after template function exit (Forum Topic 23800)
|
||||
|
||||
24.11.2012
|
||||
- made SmartyBC loadable via composer (Issue #124)
|
||||
|
||||
20.11.2012
|
||||
- bugfix assignGlobal() called from plugins did not work (Forum Topic 23771)
|
||||
|
||||
13.11.2012
|
||||
- adding attribute "strict" to html_options, html_checkboxes, html_radios to only print disabled/readonly attributes if their values are true or "disabled"/"readonly" (Issue #120)
|
||||
|
||||
01.11.2012
|
||||
- bugfix muteExcpetedErrors() would screw up for non-readable paths (Issue #118)
|
||||
|
||||
===== Smarty-3.1.12 =====
|
||||
14.09.2012
|
||||
- bugfix template inheritance failed to compile with delimiters {/ and /} (Forum Topic 23008)
|
||||
|
||||
11.09.2012
|
||||
- bugfix escape Smarty exception messages to avoid possible script execution
|
||||
|
||||
10.09.2012
|
||||
- bugfix tag option flags and shorttag attributes did not work when rdel started with '=' (Forum Topic 22979)
|
||||
|
||||
31.08.2012
|
||||
- bugfix resolving relative paths broke in some circumstances (Issue #114)
|
||||
|
||||
22.08.2012
|
||||
- bugfix test MBString availability through mb_split, as it could've been compiled without regex support (--enable-mbregex).
|
||||
Either we get MBstring's full package, or we pretend it's not there at all.
|
||||
|
||||
21.08.2012
|
||||
- bugfix $auto_literal = false did not work with { block} tags in child templates
|
||||
(problem was reintroduced after fix in 3.1.7)(Forum Topic 20581)
|
||||
|
||||
17.08.2012
|
||||
- bugfix compiled code of nocache sections could contain wrong escaping (Forum Topic 22810)
|
||||
|
||||
15.08.2012
|
||||
- bugfix template inheritance did produce wrong code if subtemplates with {block} was
|
||||
included several times (from smarty-developers forum)
|
||||
|
||||
14.08.2012
|
||||
- bugfix PHP5.2 compatibility compromised by SplFileInfo::getBasename() (Issue 110)
|
||||
|
||||
01.08.2012
|
||||
- bugfix avoid PHP error on $smarty->configLoad(...) with invalid section specification (Forum Topic 22608)
|
||||
|
||||
30.07.2012
|
||||
-bugfix {assign} in a nocache section should not overwrite existing variable values
|
||||
during compilation (issue 109)
|
||||
|
||||
28.07.2012
|
||||
- bugfix array access of config variables did not work (Forum Topic 22527)
|
||||
|
||||
19.07.2012
|
||||
- bugfix the default plugin handler did create wrong compiled code for static class methods
|
||||
from external script files (issue 108)
|
||||
|
||||
===== Smarty-3.1.11 =====
|
||||
30.06.2012
|
||||
- bugfix {block.. hide} did not work as nested child (Forum Topic 22216)
|
||||
|
||||
|
@ -342,7 +635,7 @@
|
|||
03/09/2011
|
||||
- bugfix createTemplate() must default to cache_id and compile_id of Smarty object
|
||||
- bugfix Smarty_CacheResource_KeyValueStore must include $source->uid in cache filepath to keep templates with same
|
||||
name but different folders seperated
|
||||
name but different folders separated
|
||||
- added cacheresource.apc.php example in demo folder
|
||||
|
||||
02/09/2011
|
||||
|
@ -533,7 +826,7 @@
|
|||
- changed ./ and ../ behaviour
|
||||
|
||||
14/02/2011
|
||||
- added {block ... hide} option to supress block if no child is defined
|
||||
- added {block ... hide} option to suppress block if no child is defined
|
||||
|
||||
13/02/2011
|
||||
- update handling of recursive subtemplate calls
|
||||
|
@ -647,7 +940,7 @@
|
|||
- bugfix on compiler object destruction. compiler_object property was by mistake unset.
|
||||
|
||||
09/03/2011
|
||||
-bugfix a variable filter should run before modifers on an output tag (see change of 23/07/2010)
|
||||
-bugfix a variable filter should run before modifiers on an output tag (see change of 23/07/2010)
|
||||
|
||||
08/03/2011
|
||||
- bugfix loading config file without section should load only defaults
|
||||
|
@ -951,10 +1244,10 @@ request_use_auto_globals
|
|||
- bugfix passing scope attributes in doublequoted strings did not work at {include} {assign} and {append}
|
||||
|
||||
25/07/2010
|
||||
- another bugfix of change from 23/07/2010 when compiling modifer
|
||||
- another bugfix of change from 23/07/2010 when compiling modifier
|
||||
|
||||
24/07/2010
|
||||
- bugfix of change from 23/07/2010 when compiling modifer
|
||||
- bugfix of change from 23/07/2010 when compiling modifier
|
||||
|
||||
23/07/2010
|
||||
- changed execution order. A variable filter does now run before modifiers on output of variables
|
||||
|
@ -1261,7 +1554,7 @@ request_use_auto_globals
|
|||
- bugfix on {if} tags
|
||||
|
||||
01/12/2010
|
||||
- changed back modifer handling in parser. Some restrictions still apply:
|
||||
- changed back modifier handling in parser. Some restrictions still apply:
|
||||
if modifiers are used in side {if...} expression or in mathematical expressions
|
||||
parentheses must be used.
|
||||
- bugfix the {function..} tag did not accept the name attribute in double quotes
|
||||
|
@ -1873,7 +2166,7 @@ NOTICE: existing compiled template and cache files must be deleted
|
|||
- fixed exceptions in function plugins
|
||||
- fixed notice error in Smarty.class.php
|
||||
- allow chained objects to span multiple lines
|
||||
- fixed error in modifers
|
||||
- fixed error in modifiers
|
||||
|
||||
03/20/2009
|
||||
- moved /plugins folder into /libs folder
|
||||
|
@ -1881,7 +2174,7 @@ NOTICE: existing compiled template and cache files must be deleted
|
|||
- autoappend a directory separator if the xxxxx_dir definition have no trailing one
|
||||
|
||||
03/19/2009
|
||||
- allow array definition as modifer parameter
|
||||
- allow array definition as modifier parameter
|
||||
- changed modifier to use multi byte string funktions.
|
||||
|
||||
03/17/2009
|
||||
|
|
|
@ -1,33 +1,30 @@
|
|||
<?php
|
||||
/**
|
||||
/**
|
||||
* Example Application
|
||||
|
||||
*
|
||||
* @package Example-application
|
||||
*/
|
||||
|
||||
require('../libs/Smarty.class.php');
|
||||
require '../libs/Smarty.class.php';
|
||||
|
||||
$smarty = new Smarty;
|
||||
|
||||
|
||||
|
||||
//$smarty->force_compile = true;
|
||||
$smarty->debugging = true;
|
||||
$smarty->caching = true;
|
||||
$smarty->cache_lifetime = 120;
|
||||
|
||||
$smarty->assign("Name","Fred Irving Johnathan Bradley Peppergill",true);
|
||||
$smarty->assign("FirstName",array("John","Mary","James","Henry"));
|
||||
$smarty->assign("LastName",array("Doe","Smith","Johnson","Case"));
|
||||
$smarty->assign("Class",array(array("A","B","C","D"), array("E", "F", "G", "H"),
|
||||
array("I", "J", "K", "L"), array("M", "N", "O", "P")));
|
||||
$smarty->assign("Name", "Fred Irving Johnathan Bradley Peppergill", true);
|
||||
$smarty->assign("FirstName", array("John", "Mary", "James", "Henry"));
|
||||
$smarty->assign("LastName", array("Doe", "Smith", "Johnson", "Case"));
|
||||
$smarty->assign("Class", array(array("A", "B", "C", "D"), array("E", "F", "G", "H"),
|
||||
array("I", "J", "K", "L"), array("M", "N", "O", "P")));
|
||||
|
||||
$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
|
||||
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
|
||||
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
|
||||
|
||||
$smarty->assign("option_values", array("NY","NE","KS","IA","OK","TX"));
|
||||
$smarty->assign("option_output", array("New York","Nebraska","Kansas","Iowa","Oklahoma","Texas"));
|
||||
$smarty->assign("option_values", array("NY", "NE", "KS", "IA", "OK", "TX"));
|
||||
$smarty->assign("option_output", array("New York", "Nebraska", "Kansas", "Iowa", "Oklahoma", "Texas"));
|
||||
$smarty->assign("option_selected", "NE");
|
||||
|
||||
$smarty->display('index.tpl');
|
||||
?>
|
||||
|
|
|
@ -2,19 +2,19 @@
|
|||
|
||||
/**
|
||||
* APC CacheResource
|
||||
*
|
||||
* CacheResource Implementation based on the KeyValueStore API to use
|
||||
* memcache as the storage resource for Smarty's output caching.
|
||||
* *
|
||||
*
|
||||
* @package CacheResource-examples
|
||||
* @author Uwe Tews
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore {
|
||||
|
||||
class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
// test if APC is present
|
||||
if(!function_exists('apc_cache_info')) {
|
||||
if (!function_exists('apc_cache_info')) {
|
||||
throw new Exception('APC Template Caching Error: APC is not installed');
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,9 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore {
|
|||
/**
|
||||
* Read values for a set of keys from cache
|
||||
*
|
||||
* @param array $keys list of keys to fetch
|
||||
* @return array list of values with the given keys used as indexes
|
||||
* @param array $keys list of keys to fetch
|
||||
*
|
||||
* @return array list of values with the given keys used as indexes
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function read(array $keys)
|
||||
|
@ -33,28 +34,32 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore {
|
|||
foreach ($res as $k => $v) {
|
||||
$_res[$k] = $v;
|
||||
}
|
||||
|
||||
return $_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save values for a set of keys to cache
|
||||
*
|
||||
* @param array $keys list of values to save
|
||||
* @param int $expire expiration time
|
||||
* @param array $keys list of values to save
|
||||
* @param int $expire expiration time
|
||||
*
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function write(array $keys, $expire=null)
|
||||
protected function write(array $keys, $expire = null)
|
||||
{
|
||||
foreach ($keys as $k => $v) {
|
||||
apc_store($k, $v, $expire);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove values from cache
|
||||
*
|
||||
* @param array $keys list of keys to delete
|
||||
* @param array $keys list of keys to delete
|
||||
*
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function delete(array $keys)
|
||||
|
@ -62,6 +67,7 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore {
|
|||
foreach ($keys as $k) {
|
||||
apc_delete($k);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,34 +2,35 @@
|
|||
|
||||
/**
|
||||
* Memcache CacheResource
|
||||
*
|
||||
* CacheResource Implementation based on the KeyValueStore API to use
|
||||
* memcache as the storage resource for Smarty's output caching.
|
||||
*
|
||||
* Note that memcache has a limitation of 256 characters per cache-key.
|
||||
* To avoid complications all cache-keys are translated to a sha1 hash.
|
||||
*
|
||||
* @package CacheResource-examples
|
||||
* @author Rodney Rehm
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore {
|
||||
class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
|
||||
{
|
||||
/**
|
||||
* memcache instance
|
||||
*
|
||||
* @var Memcache
|
||||
*/
|
||||
protected $memcache = null;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->memcache = new Memcache();
|
||||
$this->memcache->addServer( '127.0.0.1', 11211 );
|
||||
$this->memcache->addServer('127.0.0.1', 11211);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read values for a set of keys from cache
|
||||
*
|
||||
* @param array $keys list of keys to fetch
|
||||
* @return array list of values with the given keys used as indexes
|
||||
* @param array $keys list of keys to fetch
|
||||
*
|
||||
* @return array list of values with the given keys used as indexes
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function read(array $keys)
|
||||
|
@ -45,29 +46,33 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore {
|
|||
foreach ($res as $k => $v) {
|
||||
$_res[$lookup[$k]] = $v;
|
||||
}
|
||||
|
||||
return $_res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save values for a set of keys to cache
|
||||
*
|
||||
* @param array $keys list of values to save
|
||||
* @param int $expire expiration time
|
||||
* @param array $keys list of values to save
|
||||
* @param int $expire expiration time
|
||||
*
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function write(array $keys, $expire=null)
|
||||
protected function write(array $keys, $expire = null)
|
||||
{
|
||||
foreach ($keys as $k => $v) {
|
||||
$k = sha1($k);
|
||||
$this->memcache->set($k, $v, 0, $expire);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove values from cache
|
||||
*
|
||||
* @param array $keys list of keys to delete
|
||||
* @param array $keys list of keys to delete
|
||||
*
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function delete(array $keys)
|
||||
|
@ -76,6 +81,7 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore {
|
|||
$k = sha1($k);
|
||||
$this->memcache->delete($k);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -86,6 +92,6 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore {
|
|||
*/
|
||||
protected function purge()
|
||||
{
|
||||
return $this->memcache->flush();
|
||||
$this->memcache->flush();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
/**
|
||||
* MySQL CacheResource
|
||||
*
|
||||
* CacheResource Implementation based on the Custom API to use
|
||||
* MySQL as the storage resource for Smarty's output caching.
|
||||
*
|
||||
* Table definition:
|
||||
* <pre>CREATE TABLE IF NOT EXISTS `output_cache` (
|
||||
* `id` CHAR(40) NOT NULL COMMENT 'sha1 hash',
|
||||
|
@ -22,19 +20,22 @@
|
|||
* ) ENGINE = InnoDB;</pre>
|
||||
*
|
||||
* @package CacheResource-examples
|
||||
* @author Rodney Rehm
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom {
|
||||
class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
|
||||
{
|
||||
// PDO instance
|
||||
protected $db;
|
||||
protected $fetch;
|
||||
protected $fetchTimestamp;
|
||||
protected $save;
|
||||
|
||||
public function __construct() {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
try {
|
||||
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty", "smarty");
|
||||
} catch (PDOException $e) {
|
||||
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty");
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
|
||||
}
|
||||
$this->fetch = $this->db->prepare('SELECT modified, content FROM output_cache WHERE id = :id');
|
||||
|
@ -46,19 +47,20 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom {
|
|||
/**
|
||||
* fetch cached content and its modification time from data source
|
||||
*
|
||||
* @param string $id unique cache content identifier
|
||||
* @param string $name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param string $content cached content
|
||||
* @param integer $mtime cache modification timestamp (epoch)
|
||||
* @param string $id unique cache content identifier
|
||||
* @param string $name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param string $content cached content
|
||||
* @param integer $mtime cache modification timestamp (epoch)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function fetch($id, $name, $cache_id, $compile_id, &$content, &$mtime)
|
||||
{
|
||||
$this->fetch->execute(array('id' => $id));
|
||||
$row = $this->fetch->fetch();
|
||||
$this->fetch->closeCursor();
|
||||
$this->fetch->closeCursor();
|
||||
if ($row) {
|
||||
$content = $row['content'];
|
||||
$mtime = strtotime($row['modified']);
|
||||
|
@ -67,15 +69,17 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom {
|
|||
$mtime = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch cached content's modification timestamp from data source
|
||||
*
|
||||
* @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the complete cached content.
|
||||
* @param string $id unique cache content identifier
|
||||
* @param string $name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
*
|
||||
* @param string $id unique cache content identifier
|
||||
* @param string $name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
*
|
||||
* @return integer|boolean timestamp (epoch) the template was modified, or false if not found
|
||||
*/
|
||||
protected function fetchTimestamp($id, $name, $cache_id, $compile_id)
|
||||
|
@ -83,40 +87,44 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom {
|
|||
$this->fetchTimestamp->execute(array('id' => $id));
|
||||
$mtime = strtotime($this->fetchTimestamp->fetchColumn());
|
||||
$this->fetchTimestamp->closeCursor();
|
||||
|
||||
return $mtime;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save content to cache
|
||||
*
|
||||
* @param string $id unique cache content identifier
|
||||
* @param string $name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param integer|null $exp_time seconds till expiration time in seconds or null
|
||||
* @param string $content content to cache
|
||||
* @return boolean success
|
||||
* @param string $id unique cache content identifier
|
||||
* @param string $name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param integer|null $exp_time seconds till expiration time in seconds or null
|
||||
* @param string $content content to cache
|
||||
*
|
||||
* @return boolean success
|
||||
*/
|
||||
protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content)
|
||||
{
|
||||
$this->save->execute(array(
|
||||
'id' => $id,
|
||||
'name' => $name,
|
||||
'cache_id' => $cache_id,
|
||||
'compile_id' => $compile_id,
|
||||
'content' => $content,
|
||||
));
|
||||
'id' => $id,
|
||||
'name' => $name,
|
||||
'cache_id' => $cache_id,
|
||||
'compile_id' => $compile_id,
|
||||
'content' => $content,
|
||||
));
|
||||
|
||||
return !!$this->save->rowCount();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete content from cache
|
||||
*
|
||||
* @param string $name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param integer|null $exp_time seconds till expiration or null
|
||||
* @return integer number of deleted caches
|
||||
* @param string $name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param integer|null $exp_time seconds till expiration or null
|
||||
*
|
||||
* @return integer number of deleted caches
|
||||
*/
|
||||
protected function delete($name, $cache_id, $compile_id, $exp_time)
|
||||
{
|
||||
|
@ -124,7 +132,8 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom {
|
|||
if ($name === null && $cache_id === null && $compile_id === null && $exp_time === null) {
|
||||
// returning the number of deleted caches would require a second query to count them
|
||||
$query = $this->db->query('TRUNCATE TABLE output_cache');
|
||||
return -1;
|
||||
|
||||
return - 1;
|
||||
}
|
||||
// build the filter
|
||||
$where = array();
|
||||
|
@ -142,11 +151,12 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom {
|
|||
}
|
||||
// equal test cache_id and match sub-groups
|
||||
if ($cache_id !== null) {
|
||||
$where[] = '(cache_id = '. $this->db->quote($cache_id)
|
||||
. ' OR cache_id LIKE '. $this->db->quote($cache_id .'|%') .')';
|
||||
$where[] = '(cache_id = ' . $this->db->quote($cache_id)
|
||||
. ' OR cache_id LIKE ' . $this->db->quote($cache_id . '|%') . ')';
|
||||
}
|
||||
// run delete query
|
||||
$query = $this->db->query('DELETE FROM output_cache WHERE ' . join(' AND ', $where));
|
||||
|
||||
return $query->rowCount();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,49 +2,51 @@
|
|||
|
||||
/**
|
||||
* Extends All Resource
|
||||
*
|
||||
* Resource Implementation modifying the extends-Resource to walk
|
||||
* through the template_dirs and inherit all templates of the same name
|
||||
*
|
||||
*
|
||||
* @package Resource-examples
|
||||
* @author Rodney Rehm
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends {
|
||||
|
||||
class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends
|
||||
{
|
||||
/**
|
||||
* populate Source Object with meta data from Resource
|
||||
*
|
||||
* @param Smarty_Template_Source $source source object
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
* @param Smarty_Template_Source $source source object
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null)
|
||||
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
|
||||
{
|
||||
$uid = '';
|
||||
$sources = array();
|
||||
$exists = true;
|
||||
foreach ($_template->smarty->getTemplateDir() as $key => $directory) {
|
||||
try {
|
||||
$s = Smarty_Resource::source(null, $source->smarty, '[' . $key . ']' . $source->name );
|
||||
$s = Smarty_Resource::source(null, $source->smarty, '[' . $key . ']' . $source->name);
|
||||
if (!$s->exists) {
|
||||
continue;
|
||||
}
|
||||
$sources[$s->uid] = $s;
|
||||
$uid .= $s->filepath;
|
||||
}
|
||||
catch (SmartyException $e) {}
|
||||
catch (SmartyException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!$sources) {
|
||||
$source->exists = false;
|
||||
$source->template = $_template;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$sources = array_reverse($sources, true);
|
||||
reset($sources);
|
||||
$s = current($sources);
|
||||
|
||||
|
||||
$source->components = $sources;
|
||||
$source->filepath = $s->filepath;
|
||||
$source->uid = sha1($uid);
|
||||
|
@ -55,6 +57,4 @@ class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends {
|
|||
// need the template at getContent()
|
||||
$source->template = $_template;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
||||
|
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
/**
|
||||
* MySQL Resource
|
||||
*
|
||||
* Resource Implementation based on the Custom API to use
|
||||
* MySQL as the storage resource for Smarty's templates and configs.
|
||||
*
|
||||
* Table definition:
|
||||
* <pre>CREATE TABLE IF NOT EXISTS `templates` (
|
||||
* `name` varchar(100) NOT NULL,
|
||||
|
@ -13,14 +11,14 @@
|
|||
* `source` text,
|
||||
* PRIMARY KEY (`name`)
|
||||
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre>
|
||||
*
|
||||
* Demo data:
|
||||
* <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');</pre>
|
||||
*
|
||||
* @package Resource-examples
|
||||
* @author Rodney Rehm
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
class Smarty_Resource_Mysql extends Smarty_Resource_Custom {
|
||||
class Smarty_Resource_Mysql extends Smarty_Resource_Custom
|
||||
{
|
||||
// PDO instance
|
||||
protected $db;
|
||||
// prepared fetch() statement
|
||||
|
@ -28,22 +26,25 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom {
|
|||
// prepared fetchTimestamp() statement
|
||||
protected $mtime;
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
try {
|
||||
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty", "smarty");
|
||||
} catch (PDOException $e) {
|
||||
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty");
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
|
||||
}
|
||||
$this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name');
|
||||
$this->mtime = $this->db->prepare('SELECT modified FROM templates WHERE name = :name');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch a template and its modification time from database
|
||||
*
|
||||
* @param string $name template name
|
||||
* @param string $source template source
|
||||
* @param integer $mtime template modification timestamp (epoch)
|
||||
* @param string $name template name
|
||||
* @param string $source template source
|
||||
* @param integer $mtime template modification timestamp (epoch)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function fetch($name, &$source, &$mtime)
|
||||
|
@ -59,18 +60,22 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom {
|
|||
$mtime = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch a template's modification time from database
|
||||
*
|
||||
* @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the comple template source.
|
||||
* @param string $name template name
|
||||
*
|
||||
* @param string $name template name
|
||||
*
|
||||
* @return integer timestamp (epoch) the template was modified
|
||||
*/
|
||||
protected function fetchTimestamp($name) {
|
||||
protected function fetchTimestamp($name)
|
||||
{
|
||||
$this->mtime->execute(array('name' => $name));
|
||||
$mtime = $this->mtime->fetchColumn();
|
||||
$this->mtime->closeCursor();
|
||||
|
||||
return strtotime($mtime);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,13 +2,10 @@
|
|||
|
||||
/**
|
||||
* MySQL Resource
|
||||
*
|
||||
* Resource Implementation based on the Custom API to use
|
||||
* MySQL as the storage resource for Smarty's templates and configs.
|
||||
*
|
||||
* Note that this MySQL implementation fetches the source and timestamps in
|
||||
* a single database query, instead of two seperate like resource.mysql.php does.
|
||||
*
|
||||
* a single database query, instead of two separate like resource.mysql.php does.
|
||||
* Table definition:
|
||||
* <pre>CREATE TABLE IF NOT EXISTS `templates` (
|
||||
* `name` varchar(100) NOT NULL,
|
||||
|
@ -16,34 +13,37 @@
|
|||
* `source` text,
|
||||
* PRIMARY KEY (`name`)
|
||||
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre>
|
||||
*
|
||||
* Demo data:
|
||||
* <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');</pre>
|
||||
*
|
||||
* @package Resource-examples
|
||||
* @author Rodney Rehm
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
class Smarty_Resource_Mysqls extends Smarty_Resource_Custom {
|
||||
class Smarty_Resource_Mysqls extends Smarty_Resource_Custom
|
||||
{
|
||||
// PDO instance
|
||||
protected $db;
|
||||
// prepared fetch() statement
|
||||
protected $fetch;
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
try {
|
||||
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty", "smarty");
|
||||
} catch (PDOException $e) {
|
||||
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty");
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
|
||||
}
|
||||
$this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch a template and its modification time from database
|
||||
*
|
||||
* @param string $name template name
|
||||
* @param string $source template source
|
||||
* @param integer $mtime template modification timestamp (epoch)
|
||||
* @param string $name template name
|
||||
* @param string $source template source
|
||||
* @param integer $mtime template modification timestamp (epoch)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function fetch($name, &$source, &$mtime)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>{$title} - {$Name}</TITLE>
|
||||
<TITLE>{$title} - {$Name}</TITLE>
|
||||
</HEAD>
|
||||
<BODY bgcolor="#ffffff">
|
||||
|
|
|
@ -4,18 +4,18 @@
|
|||
<PRE>
|
||||
|
||||
{* bold and title are read from the config file *}
|
||||
{if #bold#}<b>{/if}
|
||||
{* capitalize the first letters of each word of the title *}
|
||||
Title: {#title#|capitalize}
|
||||
{if #bold#}</b>{/if}
|
||||
{if #bold#}<b>{/if}
|
||||
{* capitalize the first letters of each word of the title *}
|
||||
Title: {#title#|capitalize}
|
||||
{if #bold#}</b>{/if}
|
||||
|
||||
The current date and time is {$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
|
||||
The current date and time is {$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
|
||||
|
||||
The value of global assigned variable $SCRIPT_NAME is {$SCRIPT_NAME}
|
||||
The value of global assigned variable $SCRIPT_NAME is {$SCRIPT_NAME}
|
||||
|
||||
Example of accessing server environment variable SERVER_NAME: {$smarty.server.SERVER_NAME}
|
||||
Example of accessing server environment variable SERVER_NAME: {$smarty.server.SERVER_NAME}
|
||||
|
||||
The value of {ldelim}$Name{rdelim} is <b>{$Name}</b>
|
||||
The value of {ldelim}$Name{rdelim} is <b>{$Name}</b>
|
||||
|
||||
variable modifier example of {ldelim}$Name|upper{rdelim}
|
||||
|
||||
|
@ -24,59 +24,64 @@ variable modifier example of {ldelim}$Name|upper{rdelim}
|
|||
|
||||
An example of a section loop:
|
||||
|
||||
{section name=outer
|
||||
loop=$FirstName}
|
||||
{if $smarty.section.outer.index is odd by 2}
|
||||
{$smarty.section.outer.rownum} . {$FirstName[outer]} {$LastName[outer]}
|
||||
{else}
|
||||
{$smarty.section.outer.rownum} * {$FirstName[outer]} {$LastName[outer]}
|
||||
{/if}
|
||||
{sectionelse}
|
||||
none
|
||||
{/section}
|
||||
{section name=outer
|
||||
loop=$FirstName}
|
||||
{if $smarty.section.outer.index is odd by 2}
|
||||
{$smarty.section.outer.rownum} . {$FirstName[outer]} {$LastName[outer]}
|
||||
{else}
|
||||
{$smarty.section.outer.rownum} * {$FirstName[outer]} {$LastName[outer]}
|
||||
{/if}
|
||||
{sectionelse}
|
||||
none
|
||||
{/section}
|
||||
|
||||
An example of section looped key values:
|
||||
An example of section looped key values:
|
||||
|
||||
{section name=sec1 loop=$contacts}
|
||||
phone: {$contacts[sec1].phone}<br>
|
||||
fax: {$contacts[sec1].fax}<br>
|
||||
cell: {$contacts[sec1].cell}<br>
|
||||
{/section}
|
||||
<p>
|
||||
{section name=sec1 loop=$contacts}
|
||||
phone: {$contacts[sec1].phone}
|
||||
<br>
|
||||
|
||||
testing strip tags
|
||||
{strip}
|
||||
fax: {$contacts[sec1].fax}
|
||||
<br>
|
||||
|
||||
cell: {$contacts[sec1].cell}
|
||||
<br>
|
||||
{/section}
|
||||
<p>
|
||||
|
||||
testing strip tags
|
||||
{strip}
|
||||
<table border=0>
|
||||
<tr>
|
||||
<td>
|
||||
<A HREF="{$SCRIPT_NAME}">
|
||||
<font color="red">This is a test </font>
|
||||
</A>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<A HREF="{$SCRIPT_NAME}">
|
||||
<font color="red">This is a test </font>
|
||||
</A>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{/strip}
|
||||
{/strip}
|
||||
|
||||
</PRE>
|
||||
|
||||
This is an example of the html_select_date function:
|
||||
|
||||
<form>
|
||||
{html_select_date start_year=1998 end_year=2010}
|
||||
{html_select_date start_year=1998 end_year=2010}
|
||||
</form>
|
||||
|
||||
This is an example of the html_select_time function:
|
||||
|
||||
<form>
|
||||
{html_select_time use_24_hours=false}
|
||||
{html_select_time use_24_hours=false}
|
||||
</form>
|
||||
|
||||
This is an example of the html_options function:
|
||||
|
||||
<form>
|
||||
<select name=states>
|
||||
{html_options values=$option_values selected=$option_selected output=$option_output}
|
||||
</select>
|
||||
<select name=states>
|
||||
{html_options values=$option_values selected=$option_selected output=$option_output}
|
||||
</select>
|
||||
</form>
|
||||
|
||||
{include file="footer.tpl"}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,460 +1,467 @@
|
|||
<?php
|
||||
/**
|
||||
* Project: Smarty: the PHP compiling template engine
|
||||
* File: SmartyBC.class.php
|
||||
* SVN: $Id: $
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* For questions, help, comments, discussion, etc., please join the
|
||||
* Smarty mailing list. Send a blank e-mail to
|
||||
* smarty-discussion-subscribe@googlegroups.com
|
||||
*
|
||||
* @link http://www.smarty.net/
|
||||
* @copyright 2008 New Digital Group, Inc.
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Uwe Tews
|
||||
* @author Rodney Rehm
|
||||
* @package Smarty
|
||||
*/
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require(dirname(__FILE__) . '/Smarty.class.php');
|
||||
|
||||
/**
|
||||
* Smarty Backward Compatability Wrapper Class
|
||||
*
|
||||
* @package Smarty
|
||||
*/
|
||||
class SmartyBC extends Smarty {
|
||||
|
||||
/**
|
||||
* Smarty 2 BC
|
||||
* @var string
|
||||
*/
|
||||
public $_version = self::SMARTY_VERSION;
|
||||
|
||||
/**
|
||||
* Initialize new SmartyBC object
|
||||
*
|
||||
* @param array $options options to set during initialization, e.g. array( 'forceCompile' => false )
|
||||
*/
|
||||
public function __construct(array $options=array())
|
||||
{
|
||||
parent::__construct($options);
|
||||
// register {php} tag
|
||||
$this->registerPlugin('block', 'php', 'smarty_php_tag');
|
||||
}
|
||||
|
||||
/**
|
||||
* wrapper for assign_by_ref
|
||||
*
|
||||
* @param string $tpl_var the template variable name
|
||||
* @param mixed &$value the referenced value to assign
|
||||
*/
|
||||
public function assign_by_ref($tpl_var, &$value)
|
||||
{
|
||||
$this->assignByRef($tpl_var, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* wrapper for append_by_ref
|
||||
*
|
||||
* @param string $tpl_var the template variable name
|
||||
* @param mixed &$value the referenced value to append
|
||||
* @param boolean $merge flag if array elements shall be merged
|
||||
*/
|
||||
public function append_by_ref($tpl_var, &$value, $merge = false)
|
||||
{
|
||||
$this->appendByRef($tpl_var, $value, $merge);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear the given assigned template variable.
|
||||
*
|
||||
* @param string $tpl_var the template variable to clear
|
||||
*/
|
||||
public function clear_assign($tpl_var)
|
||||
{
|
||||
$this->clearAssign($tpl_var);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers custom function to be used in templates
|
||||
*
|
||||
* @param string $function the name of the template function
|
||||
* @param string $function_impl the name of the PHP function to register
|
||||
* @param bool $cacheable
|
||||
* @param mixed $cache_attrs
|
||||
*/
|
||||
public function register_function($function, $function_impl, $cacheable=true, $cache_attrs=null)
|
||||
{
|
||||
$this->registerPlugin('function', $function, $function_impl, $cacheable, $cache_attrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters custom function
|
||||
*
|
||||
* @param string $function name of template function
|
||||
*/
|
||||
public function unregister_function($function)
|
||||
{
|
||||
$this->unregisterPlugin('function', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers object to be used in templates
|
||||
*
|
||||
* @param string $object name of template object
|
||||
* @param object $object_impl the referenced PHP object to register
|
||||
* @param array $allowed list of allowed methods (empty = all)
|
||||
* @param boolean $smarty_args smarty argument format, else traditional
|
||||
* @param array $block_functs list of methods that are block format
|
||||
*/
|
||||
public function register_object($object, $object_impl, $allowed = array(), $smarty_args = true, $block_methods = array())
|
||||
{
|
||||
settype($allowed, 'array');
|
||||
settype($smarty_args, 'boolean');
|
||||
$this->registerObject($object, $object_impl, $allowed, $smarty_args, $block_methods);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters object
|
||||
*
|
||||
* @param string $object name of template object
|
||||
*/
|
||||
public function unregister_object($object)
|
||||
{
|
||||
$this->unregisterObject($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers block function to be used in templates
|
||||
*
|
||||
* @param string $block name of template block
|
||||
* @param string $block_impl PHP function to register
|
||||
* @param bool $cacheable
|
||||
* @param mixed $cache_attrs
|
||||
*/
|
||||
public function register_block($block, $block_impl, $cacheable=true, $cache_attrs=null)
|
||||
{
|
||||
$this->registerPlugin('block', $block, $block_impl, $cacheable, $cache_attrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters block function
|
||||
*
|
||||
* @param string $block name of template function
|
||||
*/
|
||||
public function unregister_block($block)
|
||||
{
|
||||
$this->unregisterPlugin('block', $block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers compiler function
|
||||
*
|
||||
* @param string $function name of template function
|
||||
* @param string $function_impl name of PHP function to register
|
||||
* @param bool $cacheable
|
||||
*/
|
||||
public function register_compiler_function($function, $function_impl, $cacheable=true)
|
||||
{
|
||||
$this->registerPlugin('compiler', $function, $function_impl, $cacheable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters compiler function
|
||||
*
|
||||
* @param string $function name of template function
|
||||
*/
|
||||
public function unregister_compiler_function($function)
|
||||
{
|
||||
$this->unregisterPlugin('compiler', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers modifier to be used in templates
|
||||
*
|
||||
* @param string $modifier name of template modifier
|
||||
* @param string $modifier_impl name of PHP function to register
|
||||
*/
|
||||
public function register_modifier($modifier, $modifier_impl)
|
||||
{
|
||||
$this->registerPlugin('modifier', $modifier, $modifier_impl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters modifier
|
||||
*
|
||||
* @param string $modifier name of template modifier
|
||||
*/
|
||||
public function unregister_modifier($modifier)
|
||||
{
|
||||
$this->unregisterPlugin('modifier', $modifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a resource to fetch a template
|
||||
*
|
||||
* @param string $type name of resource
|
||||
* @param array $functions array of functions to handle resource
|
||||
*/
|
||||
public function register_resource($type, $functions)
|
||||
{
|
||||
$this->registerResource($type, $functions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a resource
|
||||
*
|
||||
* @param string $type name of resource
|
||||
*/
|
||||
public function unregister_resource($type)
|
||||
{
|
||||
$this->unregisterResource($type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a prefilter function to apply
|
||||
* to a template before compiling
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function register_prefilter($function)
|
||||
{
|
||||
$this->registerFilter('pre', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a prefilter function
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function unregister_prefilter($function)
|
||||
{
|
||||
$this->unregisterFilter('pre', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a postfilter function to apply
|
||||
* to a compiled template after compilation
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function register_postfilter($function)
|
||||
{
|
||||
$this->registerFilter('post', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a postfilter function
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function unregister_postfilter($function)
|
||||
{
|
||||
$this->unregisterFilter('post', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an output filter function to apply
|
||||
* to a template output
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function register_outputfilter($function)
|
||||
{
|
||||
$this->registerFilter('output', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters an outputfilter function
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function unregister_outputfilter($function)
|
||||
{
|
||||
$this->unregisterFilter('output', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* load a filter of specified type and name
|
||||
*
|
||||
* @param string $type filter type
|
||||
* @param string $name filter name
|
||||
*/
|
||||
public function load_filter($type, $name)
|
||||
{
|
||||
$this->loadFilter($type, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear cached content for the given template and cache id
|
||||
*
|
||||
* @param string $tpl_file name of template file
|
||||
* @param string $cache_id name of cache_id
|
||||
* @param string $compile_id name of compile_id
|
||||
* @param string $exp_time expiration time
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null)
|
||||
{
|
||||
return $this->clearCache($tpl_file, $cache_id, $compile_id, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear the entire contents of cache (all templates)
|
||||
*
|
||||
* @param string $exp_time expire time
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear_all_cache($exp_time = null)
|
||||
{
|
||||
return $this->clearCache(null, null, null, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* test to see if valid cache exists for this template
|
||||
*
|
||||
* @param string $tpl_file name of template file
|
||||
* @param string $cache_id
|
||||
* @param string $compile_id
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_cached($tpl_file, $cache_id = null, $compile_id = null)
|
||||
{
|
||||
return $this->isCached($tpl_file, $cache_id, $compile_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear all the assigned template variables.
|
||||
*/
|
||||
public function clear_all_assign()
|
||||
{
|
||||
$this->clearAllAssign();
|
||||
}
|
||||
|
||||
/**
|
||||
* clears compiled version of specified template resource,
|
||||
* or all compiled template files if one is not specified.
|
||||
* This function is for advanced use only, not normally needed.
|
||||
*
|
||||
* @param string $tpl_file
|
||||
* @param string $compile_id
|
||||
* @param string $exp_time
|
||||
* @return boolean results of {@link smarty_core_rm_auto()}
|
||||
*/
|
||||
public function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null)
|
||||
{
|
||||
return $this->clearCompiledTemplate($tpl_file, $compile_id, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether requested template exists.
|
||||
*
|
||||
* @param string $tpl_file
|
||||
* @return boolean
|
||||
*/
|
||||
public function template_exists($tpl_file)
|
||||
{
|
||||
return $this->templateExists($tpl_file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing template variables
|
||||
*
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
public function get_template_vars($name=null)
|
||||
{
|
||||
return $this->getTemplateVars($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing config variables
|
||||
*
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
public function get_config_vars($name=null)
|
||||
{
|
||||
return $this->getConfigVars($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* load configuration values
|
||||
*
|
||||
* @param string $file
|
||||
* @param string $section
|
||||
* @param string $scope
|
||||
*/
|
||||
public function config_load($file, $section = null, $scope = 'global')
|
||||
{
|
||||
$this->ConfigLoad($file, $section, $scope);
|
||||
}
|
||||
|
||||
/**
|
||||
* return a reference to a registered object
|
||||
*
|
||||
* @param string $name
|
||||
* @return object
|
||||
*/
|
||||
public function get_registered_object($name)
|
||||
{
|
||||
return $this->getRegisteredObject($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear configuration values
|
||||
*
|
||||
* @param string $var
|
||||
*/
|
||||
public function clear_config($var = null)
|
||||
{
|
||||
$this->clearConfig($var);
|
||||
}
|
||||
|
||||
/**
|
||||
* trigger Smarty error
|
||||
*
|
||||
* @param string $error_msg
|
||||
* @param integer $error_type
|
||||
*/
|
||||
public function trigger_error($error_msg, $error_type = E_USER_WARNING)
|
||||
{
|
||||
trigger_error("Smarty error: $error_msg", $error_type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty {php}{/php} block function
|
||||
*
|
||||
* @param array $params parameter list
|
||||
* @param string $content contents of the block
|
||||
* @param object $template template object
|
||||
* @param boolean &$repeat repeat flag
|
||||
* @return string content re-formatted
|
||||
*/
|
||||
function smarty_php_tag($params, $content, $template, &$repeat)
|
||||
{
|
||||
eval($content);
|
||||
return '';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Project: Smarty: the PHP compiling template engine
|
||||
* File: SmartyBC.class.php
|
||||
* SVN: $Id: $
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* For questions, help, comments, discussion, etc., please join the
|
||||
* Smarty mailing list. Send a blank e-mail to
|
||||
* smarty-discussion-subscribe@googlegroups.com
|
||||
*
|
||||
* @link http://www.smarty.net/
|
||||
* @copyright 2008 New Digital Group, Inc.
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Uwe Tews
|
||||
* @author Rodney Rehm
|
||||
* @package Smarty
|
||||
*/
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require_once(dirname(__FILE__) . '/Smarty.class.php');
|
||||
|
||||
/**
|
||||
* Smarty Backward Compatability Wrapper Class
|
||||
*
|
||||
* @package Smarty
|
||||
*/
|
||||
class SmartyBC extends Smarty
|
||||
{
|
||||
/**
|
||||
* Smarty 2 BC
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $_version = self::SMARTY_VERSION;
|
||||
|
||||
/**
|
||||
* Initialize new SmartyBC object
|
||||
*
|
||||
* @param array $options options to set during initialization, e.g. array( 'forceCompile' => false )
|
||||
*/
|
||||
public function __construct(array $options = array())
|
||||
{
|
||||
parent::__construct($options);
|
||||
// register {php} tag
|
||||
$this->registerPlugin('block', 'php', 'smarty_php_tag');
|
||||
}
|
||||
|
||||
/**
|
||||
* wrapper for assign_by_ref
|
||||
*
|
||||
* @param string $tpl_var the template variable name
|
||||
* @param mixed &$value the referenced value to assign
|
||||
*/
|
||||
public function assign_by_ref($tpl_var, &$value)
|
||||
{
|
||||
$this->assignByRef($tpl_var, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* wrapper for append_by_ref
|
||||
*
|
||||
* @param string $tpl_var the template variable name
|
||||
* @param mixed &$value the referenced value to append
|
||||
* @param boolean $merge flag if array elements shall be merged
|
||||
*/
|
||||
public function append_by_ref($tpl_var, &$value, $merge = false)
|
||||
{
|
||||
$this->appendByRef($tpl_var, $value, $merge);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear the given assigned template variable.
|
||||
*
|
||||
* @param string $tpl_var the template variable to clear
|
||||
*/
|
||||
public function clear_assign($tpl_var)
|
||||
{
|
||||
$this->clearAssign($tpl_var);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers custom function to be used in templates
|
||||
*
|
||||
* @param string $function the name of the template function
|
||||
* @param string $function_impl the name of the PHP function to register
|
||||
* @param bool $cacheable
|
||||
* @param mixed $cache_attrs
|
||||
*/
|
||||
public function register_function($function, $function_impl, $cacheable = true, $cache_attrs = null)
|
||||
{
|
||||
$this->registerPlugin('function', $function, $function_impl, $cacheable, $cache_attrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters custom function
|
||||
*
|
||||
* @param string $function name of template function
|
||||
*/
|
||||
public function unregister_function($function)
|
||||
{
|
||||
$this->unregisterPlugin('function', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers object to be used in templates
|
||||
*
|
||||
* @param string $object name of template object
|
||||
* @param object $object_impl the referenced PHP object to register
|
||||
* @param array $allowed list of allowed methods (empty = all)
|
||||
* @param boolean $smarty_args smarty argument format, else traditional
|
||||
* @param array $block_methods list of methods that are block format
|
||||
*
|
||||
* @throws SmartyException
|
||||
* @internal param array $block_functs list of methods that are block format
|
||||
*/
|
||||
public function register_object($object, $object_impl, $allowed = array(), $smarty_args = true, $block_methods = array())
|
||||
{
|
||||
settype($allowed, 'array');
|
||||
settype($smarty_args, 'boolean');
|
||||
$this->registerObject($object, $object_impl, $allowed, $smarty_args, $block_methods);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters object
|
||||
*
|
||||
* @param string $object name of template object
|
||||
*/
|
||||
public function unregister_object($object)
|
||||
{
|
||||
$this->unregisterObject($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers block function to be used in templates
|
||||
*
|
||||
* @param string $block name of template block
|
||||
* @param string $block_impl PHP function to register
|
||||
* @param bool $cacheable
|
||||
* @param mixed $cache_attrs
|
||||
*/
|
||||
public function register_block($block, $block_impl, $cacheable = true, $cache_attrs = null)
|
||||
{
|
||||
$this->registerPlugin('block', $block, $block_impl, $cacheable, $cache_attrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters block function
|
||||
*
|
||||
* @param string $block name of template function
|
||||
*/
|
||||
public function unregister_block($block)
|
||||
{
|
||||
$this->unregisterPlugin('block', $block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers compiler function
|
||||
*
|
||||
* @param string $function name of template function
|
||||
* @param string $function_impl name of PHP function to register
|
||||
* @param bool $cacheable
|
||||
*/
|
||||
public function register_compiler_function($function, $function_impl, $cacheable = true)
|
||||
{
|
||||
$this->registerPlugin('compiler', $function, $function_impl, $cacheable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters compiler function
|
||||
*
|
||||
* @param string $function name of template function
|
||||
*/
|
||||
public function unregister_compiler_function($function)
|
||||
{
|
||||
$this->unregisterPlugin('compiler', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers modifier to be used in templates
|
||||
*
|
||||
* @param string $modifier name of template modifier
|
||||
* @param string $modifier_impl name of PHP function to register
|
||||
*/
|
||||
public function register_modifier($modifier, $modifier_impl)
|
||||
{
|
||||
$this->registerPlugin('modifier', $modifier, $modifier_impl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters modifier
|
||||
*
|
||||
* @param string $modifier name of template modifier
|
||||
*/
|
||||
public function unregister_modifier($modifier)
|
||||
{
|
||||
$this->unregisterPlugin('modifier', $modifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a resource to fetch a template
|
||||
*
|
||||
* @param string $type name of resource
|
||||
* @param array $functions array of functions to handle resource
|
||||
*/
|
||||
public function register_resource($type, $functions)
|
||||
{
|
||||
$this->registerResource($type, $functions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a resource
|
||||
*
|
||||
* @param string $type name of resource
|
||||
*/
|
||||
public function unregister_resource($type)
|
||||
{
|
||||
$this->unregisterResource($type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a prefilter function to apply
|
||||
* to a template before compiling
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function register_prefilter($function)
|
||||
{
|
||||
$this->registerFilter('pre', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a prefilter function
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function unregister_prefilter($function)
|
||||
{
|
||||
$this->unregisterFilter('pre', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a postfilter function to apply
|
||||
* to a compiled template after compilation
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function register_postfilter($function)
|
||||
{
|
||||
$this->registerFilter('post', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a postfilter function
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function unregister_postfilter($function)
|
||||
{
|
||||
$this->unregisterFilter('post', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an output filter function to apply
|
||||
* to a template output
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function register_outputfilter($function)
|
||||
{
|
||||
$this->registerFilter('output', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters an outputfilter function
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function unregister_outputfilter($function)
|
||||
{
|
||||
$this->unregisterFilter('output', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* load a filter of specified type and name
|
||||
*
|
||||
* @param string $type filter type
|
||||
* @param string $name filter name
|
||||
*/
|
||||
public function load_filter($type, $name)
|
||||
{
|
||||
$this->loadFilter($type, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear cached content for the given template and cache id
|
||||
*
|
||||
* @param string $tpl_file name of template file
|
||||
* @param string $cache_id name of cache_id
|
||||
* @param string $compile_id name of compile_id
|
||||
* @param string $exp_time expiration time
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null)
|
||||
{
|
||||
return $this->clearCache($tpl_file, $cache_id, $compile_id, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear the entire contents of cache (all templates)
|
||||
*
|
||||
* @param string $exp_time expire time
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear_all_cache($exp_time = null)
|
||||
{
|
||||
return $this->clearCache(null, null, null, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* test to see if valid cache exists for this template
|
||||
*
|
||||
* @param string $tpl_file name of template file
|
||||
* @param string $cache_id
|
||||
* @param string $compile_id
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_cached($tpl_file, $cache_id = null, $compile_id = null)
|
||||
{
|
||||
return $this->isCached($tpl_file, $cache_id, $compile_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear all the assigned template variables.
|
||||
*/
|
||||
public function clear_all_assign()
|
||||
{
|
||||
$this->clearAllAssign();
|
||||
}
|
||||
|
||||
/**
|
||||
* clears compiled version of specified template resource,
|
||||
* or all compiled template files if one is not specified.
|
||||
* This function is for advanced use only, not normally needed.
|
||||
*
|
||||
* @param string $tpl_file
|
||||
* @param string $compile_id
|
||||
* @param string $exp_time
|
||||
*
|
||||
* @return boolean results of {@link smarty_core_rm_auto()}
|
||||
*/
|
||||
public function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null)
|
||||
{
|
||||
return $this->clearCompiledTemplate($tpl_file, $compile_id, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether requested template exists.
|
||||
*
|
||||
* @param string $tpl_file
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function template_exists($tpl_file)
|
||||
{
|
||||
return $this->templateExists($tpl_file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing template variables
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_template_vars($name = null)
|
||||
{
|
||||
return $this->getTemplateVars($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing config variables
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_config_vars($name = null)
|
||||
{
|
||||
return $this->getConfigVars($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* load configuration values
|
||||
*
|
||||
* @param string $file
|
||||
* @param string $section
|
||||
* @param string $scope
|
||||
*/
|
||||
public function config_load($file, $section = null, $scope = 'global')
|
||||
{
|
||||
$this->ConfigLoad($file, $section, $scope);
|
||||
}
|
||||
|
||||
/**
|
||||
* return a reference to a registered object
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function get_registered_object($name)
|
||||
{
|
||||
return $this->getRegisteredObject($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear configuration values
|
||||
*
|
||||
* @param string $var
|
||||
*/
|
||||
public function clear_config($var = null)
|
||||
{
|
||||
$this->clearConfig($var);
|
||||
}
|
||||
|
||||
/**
|
||||
* trigger Smarty error
|
||||
*
|
||||
* @param string $error_msg
|
||||
* @param integer $error_type
|
||||
*/
|
||||
public function trigger_error($error_msg, $error_type = E_USER_WARNING)
|
||||
{
|
||||
trigger_error("Smarty error: $error_msg", $error_type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty {php}{/php} block function
|
||||
*
|
||||
* @param array $params parameter list
|
||||
* @param string $content contents of the block
|
||||
* @param object $template template object
|
||||
* @param boolean &$repeat repeat flag
|
||||
*
|
||||
* @return string content re-formatted
|
||||
*/
|
||||
function smarty_php_tag($params, $content, $template, &$repeat)
|
||||
{
|
||||
eval($content);
|
||||
|
||||
return '';
|
||||
}
|
||||
|
|
|
@ -1,133 +1,137 @@
|
|||
{capture name='_smarty_debug' assign=debug_output}
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<title>Smarty Debug Console</title>
|
||||
<style type="text/css">
|
||||
{literal}
|
||||
body, h1, h2, td, th, p {
|
||||
font-family: sans-serif;
|
||||
font-weight: normal;
|
||||
font-size: 0.9em;
|
||||
margin: 1px;
|
||||
padding: 0;
|
||||
}
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<title>Smarty Debug Console</title>
|
||||
<style type="text/css">
|
||||
{literal}
|
||||
body, h1, h2, td, th, p {
|
||||
font-family: sans-serif;
|
||||
font-weight: normal;
|
||||
font-size: 0.9em;
|
||||
margin: 1px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
text-align: left;
|
||||
padding: 2px;
|
||||
background-color: #f0c040;
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
h1 {
|
||||
margin: 0;
|
||||
text-align: left;
|
||||
padding: 2px;
|
||||
background-color: #f0c040;
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
background-color: #9B410E;
|
||||
color: white;
|
||||
text-align: left;
|
||||
font-weight: bold;
|
||||
padding: 2px;
|
||||
border-top: 1px solid black;
|
||||
}
|
||||
h2 {
|
||||
background-color: #9B410E;
|
||||
color: white;
|
||||
text-align: left;
|
||||
font-weight: bold;
|
||||
padding: 2px;
|
||||
border-top: 1px solid black;
|
||||
}
|
||||
|
||||
body {
|
||||
background: black;
|
||||
}
|
||||
body {
|
||||
background: black;
|
||||
}
|
||||
|
||||
p, table, div {
|
||||
background: #f0ead8;
|
||||
}
|
||||
p, table, div {
|
||||
background: #f0ead8;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
font-style: italic;
|
||||
text-align: center;
|
||||
}
|
||||
p {
|
||||
margin: 0;
|
||||
font-style: italic;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
th, td {
|
||||
font-family: monospace;
|
||||
vertical-align: top;
|
||||
text-align: left;
|
||||
width: 50%;
|
||||
}
|
||||
th, td {
|
||||
font-family: monospace;
|
||||
vertical-align: top;
|
||||
text-align: left;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
td {
|
||||
color: green;
|
||||
}
|
||||
td {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.odd {
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
.odd {
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
|
||||
.even {
|
||||
background-color: #fafafa;
|
||||
}
|
||||
.even {
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
.exectime {
|
||||
font-size: 0.8em;
|
||||
font-style: italic;
|
||||
}
|
||||
.exectime {
|
||||
font-size: 0.8em;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#table_assigned_vars th {
|
||||
color: blue;
|
||||
}
|
||||
#table_assigned_vars th {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
#table_config_vars th {
|
||||
color: maroon;
|
||||
}
|
||||
{/literal}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
#table_config_vars th {
|
||||
color: maroon;
|
||||
}
|
||||
|
||||
<h1>Smarty Debug Console - {if isset($template_name)}{$template_name|debug_print_var nofilter}{else}Total Time {$execution_time|string_format:"%.5f"}{/if}</h1>
|
||||
{/literal}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
{if !empty($template_data)}
|
||||
<h2>included templates & config files (load time in seconds)</h2>
|
||||
<h1>Smarty Debug Console
|
||||
- {if isset($template_name)}{$template_name|debug_print_var nofilter}{else}Total Time {$execution_time|string_format:"%.5f"}{/if}</h1>
|
||||
|
||||
<div>
|
||||
{foreach $template_data as $template}
|
||||
<font color=brown>{$template.name}</font>
|
||||
<span class="exectime">
|
||||
(compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"})
|
||||
{if !empty($template_data)}
|
||||
<h2>included templates & config files (load time in seconds)</h2>
|
||||
<div>
|
||||
{foreach $template_data as $template}
|
||||
<font color=brown>{$template.name}</font>
|
||||
<span class="exectime">
|
||||
(compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"}
|
||||
)
|
||||
</span>
|
||||
<br>
|
||||
{/foreach}
|
||||
</div>
|
||||
{/if}
|
||||
<br>
|
||||
{/foreach}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<h2>assigned template variables</h2>
|
||||
<h2>assigned template variables</h2>
|
||||
|
||||
<table id="table_assigned_vars">
|
||||
{foreach $assigned_vars as $vars}
|
||||
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
|
||||
<th>${$vars@key|escape:'html'}</th>
|
||||
<td>{$vars|debug_print_var nofilter}</td></tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
<table id="table_assigned_vars">
|
||||
{foreach $assigned_vars as $vars}
|
||||
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
|
||||
<th>${$vars@key|escape:'html'}</th>
|
||||
<td>{$vars|debug_print_var nofilter}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
|
||||
<h2>assigned config file variables (outer template scope)</h2>
|
||||
<h2>assigned config file variables (outer template scope)</h2>
|
||||
|
||||
<table id="table_config_vars">
|
||||
{foreach $config_vars as $vars}
|
||||
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
|
||||
<th>{$vars@key|escape:'html'}</th>
|
||||
<td>{$vars|debug_print_var nofilter}</td></tr>
|
||||
{/foreach}
|
||||
<table id="table_config_vars">
|
||||
{foreach $config_vars as $vars}
|
||||
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
|
||||
<th>{$vars@key|escape:'html'}</th>
|
||||
<td>{$vars|debug_print_var nofilter}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
{/capture}
|
||||
<script type="text/javascript">
|
||||
{$id = $template_name|default:''|md5}
|
||||
_smarty_console = window.open("","console{$id}","width=680,height=600,resizable,scrollbars=yes");
|
||||
{$id = $template_name|default:''|md5}
|
||||
_smarty_console = window.open("", "console{$id}", "width=680,height=600,resizable,scrollbars=yes");
|
||||
_smarty_console.document.write("{$debug_output|escape:'javascript' nofilter}");
|
||||
_smarty_console.document.close();
|
||||
</script>
|
||||
|
|
|
@ -2,13 +2,12 @@
|
|||
/**
|
||||
* Smarty plugin to format text blocks
|
||||
*
|
||||
* @package Smarty
|
||||
* @package Smarty
|
||||
* @subpackage PluginsBlock
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {textformat}{/textformat} block plugin
|
||||
*
|
||||
* Type: block function<br>
|
||||
* Name: textformat<br>
|
||||
* Purpose: format text a certain way with preset styles
|
||||
|
@ -23,12 +22,14 @@
|
|||
* - wrap_boundary - boolean (true)
|
||||
* </pre>
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat}
|
||||
* (Smarty online manual)
|
||||
* @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat}
|
||||
* (Smarty online manual)
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param string $content contents of the block
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
* @param boolean &$repeat repeat flag
|
||||
*
|
||||
* @return string content re-formatted
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*/
|
||||
|
@ -53,17 +54,17 @@ function smarty_block_textformat($params, $content, $template, &$repeat)
|
|||
case 'indent_char':
|
||||
case 'wrap_char':
|
||||
case 'assign':
|
||||
$$_key = (string)$_val;
|
||||
$$_key = (string) $_val;
|
||||
break;
|
||||
|
||||
case 'indent':
|
||||
case 'indent_first':
|
||||
case 'wrap':
|
||||
$$_key = (int)$_val;
|
||||
$$_key = (int) $_val;
|
||||
break;
|
||||
|
||||
case 'wrap_cut':
|
||||
$$_key = (bool)$_val;
|
||||
$$_key = (bool) $_val;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -76,8 +77,6 @@ function smarty_block_textformat($params, $content, $template, &$repeat)
|
|||
}
|
||||
// split into paragraphs
|
||||
$_paragraphs = preg_split('![\r\n]{2}!', $content);
|
||||
$_output = '';
|
||||
|
||||
|
||||
foreach ($_paragraphs as &$_paragraph) {
|
||||
if (!$_paragraph) {
|
||||
|
@ -102,12 +101,10 @@ function smarty_block_textformat($params, $content, $template, &$repeat)
|
|||
}
|
||||
}
|
||||
$_output = implode($wrap_char . $wrap_char, $_paragraphs);
|
||||
|
||||
|
||||
if ($assign) {
|
||||
$template->assign($assign, $_output);
|
||||
} else {
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,22 +1,24 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {counter} function plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: counter<br>
|
||||
* Purpose: print out a counter value
|
||||
*
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @link http://www.smarty.net/manual/en/language.function.counter.php {counter}
|
||||
* (Smarty online manual)
|
||||
* @link http://www.smarty.net/manual/en/language.function.counter.php {counter}
|
||||
* (Smarty online manual)
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
function smarty_function_counter($params, $template)
|
||||
|
@ -26,16 +28,16 @@ function smarty_function_counter($params, $template)
|
|||
$name = (isset($params['name'])) ? $params['name'] : 'default';
|
||||
if (!isset($counters[$name])) {
|
||||
$counters[$name] = array(
|
||||
'start'=>1,
|
||||
'skip'=>1,
|
||||
'direction'=>'up',
|
||||
'count'=>1
|
||||
);
|
||||
'start' => 1,
|
||||
'skip' => 1,
|
||||
'direction' => 'up',
|
||||
'count' => 1
|
||||
);
|
||||
}
|
||||
$counter =& $counters[$name];
|
||||
|
||||
if (isset($params['start'])) {
|
||||
$counter['start'] = $counter['count'] = (int)$params['start'];
|
||||
$counter['start'] = $counter['count'] = (int) $params['start'];
|
||||
}
|
||||
|
||||
if (!empty($params['assign'])) {
|
||||
|
@ -45,9 +47,9 @@ function smarty_function_counter($params, $template)
|
|||
if (isset($counter['assign'])) {
|
||||
$template->assign($counter['assign'], $counter['count']);
|
||||
}
|
||||
|
||||
|
||||
if (isset($params['print'])) {
|
||||
$print = (bool)$params['print'];
|
||||
$print = (bool) $params['print'];
|
||||
} else {
|
||||
$print = empty($counter['assign']);
|
||||
}
|
||||
|
@ -61,18 +63,16 @@ function smarty_function_counter($params, $template)
|
|||
if (isset($params['skip'])) {
|
||||
$counter['skip'] = $params['skip'];
|
||||
}
|
||||
|
||||
|
||||
if (isset($params['direction'])) {
|
||||
$counter['direction'] = $params['direction'];
|
||||
}
|
||||
|
||||
if ($counter['direction'] == "down")
|
||||
if ($counter['direction'] == "down") {
|
||||
$counter['count'] -= $counter['skip'];
|
||||
else
|
||||
} else {
|
||||
$counter['count'] += $counter['skip'];
|
||||
|
||||
return $retval;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
return $retval;
|
||||
}
|
||||
|
|
|
@ -2,13 +2,12 @@
|
|||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {cycle} function plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: cycle<br>
|
||||
* Date: May 3, 2002<br>
|
||||
|
@ -31,15 +30,17 @@
|
|||
* {cycle name=row}
|
||||
* </pre>
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author credit to Mark Priatel <mpriatel@rogers.com>
|
||||
* @author credit to Gerard <gerard@interfold.com>
|
||||
* @author credit to Jason Sweat <jsweat_php@yahoo.com>
|
||||
* @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author credit to Mark Priatel <mpriatel@rogers.com>
|
||||
* @author credit to Gerard <gerard@interfold.com>
|
||||
* @author credit to Jason Sweat <jsweat_php@yahoo.com>
|
||||
* @version 1.3
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
|
||||
|
@ -48,18 +49,20 @@ function smarty_function_cycle($params, $template)
|
|||
static $cycle_vars;
|
||||
|
||||
$name = (empty($params['name'])) ? 'default' : $params['name'];
|
||||
$print = (isset($params['print'])) ? (bool)$params['print'] : true;
|
||||
$advance = (isset($params['advance'])) ? (bool)$params['advance'] : true;
|
||||
$reset = (isset($params['reset'])) ? (bool)$params['reset'] : false;
|
||||
$print = (isset($params['print'])) ? (bool) $params['print'] : true;
|
||||
$advance = (isset($params['advance'])) ? (bool) $params['advance'] : true;
|
||||
$reset = (isset($params['reset'])) ? (bool) $params['reset'] : false;
|
||||
|
||||
if (!isset($params['values'])) {
|
||||
if(!isset($cycle_vars[$name]['values'])) {
|
||||
if (!isset($cycle_vars[$name]['values'])) {
|
||||
trigger_error("cycle: missing 'values' parameter");
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if(isset($cycle_vars[$name]['values'])
|
||||
&& $cycle_vars[$name]['values'] != $params['values'] ) {
|
||||
if (isset($cycle_vars[$name]['values'])
|
||||
&& $cycle_vars[$name]['values'] != $params['values']
|
||||
) {
|
||||
$cycle_vars[$name]['index'] = 0;
|
||||
}
|
||||
$cycle_vars[$name]['values'] = $params['values'];
|
||||
|
@ -71,13 +74,13 @@ function smarty_function_cycle($params, $template)
|
|||
$cycle_vars[$name]['delimiter'] = ',';
|
||||
}
|
||||
|
||||
if(is_array($cycle_vars[$name]['values'])) {
|
||||
if (is_array($cycle_vars[$name]['values'])) {
|
||||
$cycle_array = $cycle_vars[$name]['values'];
|
||||
} else {
|
||||
$cycle_array = explode($cycle_vars[$name]['delimiter'],$cycle_vars[$name]['values']);
|
||||
$cycle_array = explode($cycle_vars[$name]['delimiter'], $cycle_vars[$name]['values']);
|
||||
}
|
||||
|
||||
if(!isset($cycle_vars[$name]['index']) || $reset ) {
|
||||
if (!isset($cycle_vars[$name]['index']) || $reset) {
|
||||
$cycle_vars[$name]['index'] = 0;
|
||||
}
|
||||
|
||||
|
@ -86,21 +89,19 @@ function smarty_function_cycle($params, $template)
|
|||
$template->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]);
|
||||
}
|
||||
|
||||
if($print) {
|
||||
if ($print) {
|
||||
$retval = $cycle_array[$cycle_vars[$name]['index']];
|
||||
} else {
|
||||
$retval = null;
|
||||
}
|
||||
|
||||
if($advance) {
|
||||
if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) {
|
||||
if ($advance) {
|
||||
if ($cycle_vars[$name]['index'] >= count($cycle_array) - 1) {
|
||||
$cycle_vars[$name]['index'] = 0;
|
||||
} else {
|
||||
$cycle_vars[$name]['index']++;
|
||||
$cycle_vars[$name]['index'] ++;
|
||||
}
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
?>
|
|
@ -2,50 +2,53 @@
|
|||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {fetch} plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: fetch<br>
|
||||
* Purpose: fetch file, web or ftp data and display results
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.fetch.php {fetch}
|
||||
* (Smarty online manual)
|
||||
* @link http://www.smarty.net/manual/en/language.function.fetch.php {fetch}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
*
|
||||
* @throws SmartyException
|
||||
* @return string|null if the assign parameter is passed, Smarty assigns the result to a template variable
|
||||
*/
|
||||
function smarty_function_fetch($params, $template)
|
||||
{
|
||||
if (empty($params['file'])) {
|
||||
trigger_error("[plugin] fetch parameter 'file' cannot be empty",E_USER_NOTICE);
|
||||
trigger_error("[plugin] fetch parameter 'file' cannot be empty", E_USER_NOTICE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// strip file protocol
|
||||
if (stripos($params['file'], 'file://') === 0) {
|
||||
$params['file'] = substr($params['file'], 7);
|
||||
}
|
||||
|
||||
|
||||
$protocol = strpos($params['file'], '://');
|
||||
if ($protocol !== false) {
|
||||
$protocol = strtolower(substr($params['file'], 0, $protocol));
|
||||
}
|
||||
|
||||
|
||||
if (isset($template->smarty->security_policy)) {
|
||||
if ($protocol) {
|
||||
// remote resource (or php stream, …)
|
||||
if(!$template->smarty->security_policy->isTrustedUri($params['file'])) {
|
||||
if (!$template->smarty->security_policy->isTrustedUri($params['file'])) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// local file
|
||||
if(!$template->smarty->security_policy->isTrustedResourceDir($params['file'])) {
|
||||
if (!$template->smarty->security_policy->isTrustedResourceDir($params['file'])) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -54,53 +57,54 @@ function smarty_function_fetch($params, $template)
|
|||
$content = '';
|
||||
if ($protocol == 'http') {
|
||||
// http fetch
|
||||
if($uri_parts = parse_url($params['file'])) {
|
||||
if ($uri_parts = parse_url($params['file'])) {
|
||||
// set defaults
|
||||
$host = $server_name = $uri_parts['host'];
|
||||
$timeout = 30;
|
||||
$accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
|
||||
$agent = "Smarty Template Engine ". Smarty::SMARTY_VERSION;
|
||||
$agent = "Smarty Template Engine " . Smarty::SMARTY_VERSION;
|
||||
$referer = "";
|
||||
$uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/';
|
||||
$uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : '';
|
||||
$_is_proxy = false;
|
||||
if(empty($uri_parts['port'])) {
|
||||
if (empty($uri_parts['port'])) {
|
||||
$port = 80;
|
||||
} else {
|
||||
$port = $uri_parts['port'];
|
||||
}
|
||||
if(!empty($uri_parts['user'])) {
|
||||
if (!empty($uri_parts['user'])) {
|
||||
$user = $uri_parts['user'];
|
||||
}
|
||||
if(!empty($uri_parts['pass'])) {
|
||||
if (!empty($uri_parts['pass'])) {
|
||||
$pass = $uri_parts['pass'];
|
||||
}
|
||||
// loop through parameters, setup headers
|
||||
foreach($params as $param_key => $param_value) {
|
||||
switch($param_key) {
|
||||
foreach ($params as $param_key => $param_value) {
|
||||
switch ($param_key) {
|
||||
case "file":
|
||||
case "assign":
|
||||
case "assign_headers":
|
||||
break;
|
||||
case "user":
|
||||
if(!empty($param_value)) {
|
||||
if (!empty($param_value)) {
|
||||
$user = $param_value;
|
||||
}
|
||||
break;
|
||||
case "pass":
|
||||
if(!empty($param_value)) {
|
||||
if (!empty($param_value)) {
|
||||
$pass = $param_value;
|
||||
}
|
||||
break;
|
||||
case "accept":
|
||||
if(!empty($param_value)) {
|
||||
if (!empty($param_value)) {
|
||||
$accept = $param_value;
|
||||
}
|
||||
break;
|
||||
case "header":
|
||||
if(!empty($param_value)) {
|
||||
if(!preg_match('![\w\d-]+: .+!',$param_value)) {
|
||||
trigger_error("[plugin] invalid header format '".$param_value."'",E_USER_NOTICE);
|
||||
if (!empty($param_value)) {
|
||||
if (!preg_match('![\w\d-]+: .+!', $param_value)) {
|
||||
trigger_error("[plugin] invalid header format '" . $param_value . "'", E_USER_NOTICE);
|
||||
|
||||
return;
|
||||
} else {
|
||||
$extra_headers[] = $param_value;
|
||||
|
@ -108,99 +112,104 @@ function smarty_function_fetch($params, $template)
|
|||
}
|
||||
break;
|
||||
case "proxy_host":
|
||||
if(!empty($param_value)) {
|
||||
if (!empty($param_value)) {
|
||||
$proxy_host = $param_value;
|
||||
}
|
||||
break;
|
||||
case "proxy_port":
|
||||
if(!preg_match('!\D!', $param_value)) {
|
||||
if (!preg_match('!\D!', $param_value)) {
|
||||
$proxy_port = (int) $param_value;
|
||||
} else {
|
||||
trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE);
|
||||
trigger_error("[plugin] invalid value for attribute '" . $param_key . "'", E_USER_NOTICE);
|
||||
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case "agent":
|
||||
if(!empty($param_value)) {
|
||||
if (!empty($param_value)) {
|
||||
$agent = $param_value;
|
||||
}
|
||||
break;
|
||||
case "referer":
|
||||
if(!empty($param_value)) {
|
||||
if (!empty($param_value)) {
|
||||
$referer = $param_value;
|
||||
}
|
||||
break;
|
||||
case "timeout":
|
||||
if(!preg_match('!\D!', $param_value)) {
|
||||
if (!preg_match('!\D!', $param_value)) {
|
||||
$timeout = (int) $param_value;
|
||||
} else {
|
||||
trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE);
|
||||
trigger_error("[plugin] invalid value for attribute '" . $param_key . "'", E_USER_NOTICE);
|
||||
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
trigger_error("[plugin] unrecognized attribute '".$param_key."'",E_USER_NOTICE);
|
||||
trigger_error("[plugin] unrecognized attribute '" . $param_key . "'", E_USER_NOTICE);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(!empty($proxy_host) && !empty($proxy_port)) {
|
||||
if (!empty($proxy_host) && !empty($proxy_port)) {
|
||||
$_is_proxy = true;
|
||||
$fp = fsockopen($proxy_host,$proxy_port,$errno,$errstr,$timeout);
|
||||
$fp = fsockopen($proxy_host, $proxy_port, $errno, $errstr, $timeout);
|
||||
} else {
|
||||
$fp = fsockopen($server_name,$port,$errno,$errstr,$timeout);
|
||||
$fp = fsockopen($server_name, $port, $errno, $errstr, $timeout);
|
||||
}
|
||||
|
||||
if(!$fp) {
|
||||
trigger_error("[plugin] unable to fetch: $errstr ($errno)",E_USER_NOTICE);
|
||||
if (!$fp) {
|
||||
trigger_error("[plugin] unable to fetch: $errstr ($errno)", E_USER_NOTICE);
|
||||
|
||||
return;
|
||||
} else {
|
||||
if($_is_proxy) {
|
||||
if ($_is_proxy) {
|
||||
fputs($fp, 'GET ' . $params['file'] . " HTTP/1.0\r\n");
|
||||
} else {
|
||||
fputs($fp, "GET $uri HTTP/1.0\r\n");
|
||||
}
|
||||
if(!empty($host)) {
|
||||
if (!empty($host)) {
|
||||
fputs($fp, "Host: $host\r\n");
|
||||
}
|
||||
if(!empty($accept)) {
|
||||
if (!empty($accept)) {
|
||||
fputs($fp, "Accept: $accept\r\n");
|
||||
}
|
||||
if(!empty($agent)) {
|
||||
if (!empty($agent)) {
|
||||
fputs($fp, "User-Agent: $agent\r\n");
|
||||
}
|
||||
if(!empty($referer)) {
|
||||
if (!empty($referer)) {
|
||||
fputs($fp, "Referer: $referer\r\n");
|
||||
}
|
||||
if(isset($extra_headers) && is_array($extra_headers)) {
|
||||
foreach($extra_headers as $curr_header) {
|
||||
fputs($fp, $curr_header."\r\n");
|
||||
if (isset($extra_headers) && is_array($extra_headers)) {
|
||||
foreach ($extra_headers as $curr_header) {
|
||||
fputs($fp, $curr_header . "\r\n");
|
||||
}
|
||||
}
|
||||
if(!empty($user) && !empty($pass)) {
|
||||
fputs($fp, "Authorization: BASIC ".base64_encode("$user:$pass")."\r\n");
|
||||
if (!empty($user) && !empty($pass)) {
|
||||
fputs($fp, "Authorization: BASIC " . base64_encode("$user:$pass") . "\r\n");
|
||||
}
|
||||
|
||||
fputs($fp, "\r\n");
|
||||
while(!feof($fp)) {
|
||||
$content .= fgets($fp,4096);
|
||||
while (!feof($fp)) {
|
||||
$content .= fgets($fp, 4096);
|
||||
}
|
||||
fclose($fp);
|
||||
$csplit = preg_split("!\r\n\r\n!",$content,2);
|
||||
$csplit = preg_split("!\r\n\r\n!", $content, 2);
|
||||
|
||||
$content = $csplit[1];
|
||||
|
||||
if(!empty($params['assign_headers'])) {
|
||||
$template->assign($params['assign_headers'],preg_split("!\r\n!",$csplit[0]));
|
||||
if (!empty($params['assign_headers'])) {
|
||||
$template->assign($params['assign_headers'], preg_split("!\r\n!", $csplit[0]));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
trigger_error("[plugin fetch] unable to parse URL, check syntax",E_USER_NOTICE);
|
||||
trigger_error("[plugin fetch] unable to parse URL, check syntax", E_USER_NOTICE);
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$content = @file_get_contents($params['file']);
|
||||
if ($content === false) {
|
||||
throw new SmartyException("{fetch} cannot read resource '" . $params['file'] ."'");
|
||||
throw new SmartyException("{fetch} cannot read resource '" . $params['file'] . "'");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -210,5 +219,3 @@ function smarty_function_fetch($params, $template)
|
|||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -2,13 +2,12 @@
|
|||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {html_checkboxes} function plugin
|
||||
*
|
||||
* File: function.html_checkboxes.php<br>
|
||||
* Type: function<br>
|
||||
* Name: html_checkboxes<br>
|
||||
|
@ -32,15 +31,17 @@
|
|||
* - escape (optional) - escape the content (not value), defaults to true
|
||||
* </pre>
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
|
||||
* (Smarty online manual)
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
|
||||
* (Smarty online manual)
|
||||
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
|
||||
* @author credits to Monte Ohrt <monte at ohrt dot com>
|
||||
* @author credits to Monte Ohrt <monte at ohrt dot com>
|
||||
* @version 1.0
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param object $template template object
|
||||
*
|
||||
* @return string
|
||||
* @uses smarty_function_escape_special_chars()
|
||||
* @uses smarty_function_escape_special_chars()
|
||||
*/
|
||||
function smarty_function_html_checkboxes($params, $template)
|
||||
{
|
||||
|
@ -58,8 +59,8 @@ function smarty_function_html_checkboxes($params, $template)
|
|||
|
||||
$extra = '';
|
||||
|
||||
foreach($params as $_key => $_val) {
|
||||
switch($_key) {
|
||||
foreach ($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'name':
|
||||
case 'separator':
|
||||
$$_key = (string) $_val;
|
||||
|
@ -89,7 +90,7 @@ function smarty_function_html_checkboxes($params, $template)
|
|||
if (method_exists($_sel, "__toString")) {
|
||||
$_sel = smarty_function_escape_special_chars((string) $_sel->__toString());
|
||||
} else {
|
||||
trigger_error("html_checkboxes: selected attribute contains an object of class '". get_class($_sel) ."' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error("html_checkboxes: selected attribute contains an object of class '" . get_class($_sel) . "' without __toString() method", E_USER_NOTICE);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
|
@ -101,7 +102,7 @@ function smarty_function_html_checkboxes($params, $template)
|
|||
if (method_exists($_val, "__toString")) {
|
||||
$selected = smarty_function_escape_special_chars((string) $_val->__toString());
|
||||
} else {
|
||||
trigger_error("html_checkboxes: selected attribute is an object of class '". get_class($_val) ."' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error("html_checkboxes: selected attribute is an object of class '" . get_class($_val) . "' without __toString() method", E_USER_NOTICE);
|
||||
}
|
||||
} else {
|
||||
$selected = smarty_function_escape_special_chars((string) $_val);
|
||||
|
@ -116,9 +117,27 @@ function smarty_function_html_checkboxes($params, $template)
|
|||
case 'assign':
|
||||
break;
|
||||
|
||||
case 'strict':
|
||||
break;
|
||||
|
||||
case 'disabled':
|
||||
case 'readonly':
|
||||
if (!empty($params['strict'])) {
|
||||
if (!is_scalar($_val)) {
|
||||
trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute", E_USER_NOTICE);
|
||||
}
|
||||
|
||||
if ($_val === true || $_val === $_key) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"';
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
// omit break; to fall through!
|
||||
|
||||
default:
|
||||
if(!is_array($_val)) {
|
||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||
} else {
|
||||
trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
|
@ -126,76 +145,79 @@ function smarty_function_html_checkboxes($params, $template)
|
|||
}
|
||||
}
|
||||
|
||||
if (!isset($options) && !isset($values))
|
||||
return ''; /* raise error here? */
|
||||
if (!isset($options) && !isset($values)) {
|
||||
return '';
|
||||
} /* raise error here? */
|
||||
|
||||
$_html_result = array();
|
||||
|
||||
if (isset($options)) {
|
||||
foreach ($options as $_key=>$_val) {
|
||||
foreach ($options as $_key => $_val) {
|
||||
$_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids, $escape);
|
||||
}
|
||||
} else {
|
||||
foreach ($values as $_i=>$_key) {
|
||||
foreach ($values as $_i => $_key) {
|
||||
$_val = isset($output[$_i]) ? $output[$_i] : '';
|
||||
$_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids, $escape);
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($params['assign'])) {
|
||||
if (!empty($params['assign'])) {
|
||||
$template->assign($params['assign'], $_html_result);
|
||||
} else {
|
||||
return implode("\n", $_html_result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids, $escape=true) {
|
||||
function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids, $escape = true)
|
||||
{
|
||||
$_output = '';
|
||||
|
||||
|
||||
if (is_object($value)) {
|
||||
if (method_exists($value, "__toString")) {
|
||||
$value = (string) $value->__toString();
|
||||
} else {
|
||||
trigger_error("html_options: value is an object of class '". get_class($value) ."' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error("html_options: value is an object of class '" . get_class($value) . "' without __toString() method", E_USER_NOTICE);
|
||||
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
$value = (string) $value;
|
||||
}
|
||||
|
||||
|
||||
if (is_object($output)) {
|
||||
if (method_exists($output, "__toString")) {
|
||||
$output = (string) $output->__toString();
|
||||
} else {
|
||||
trigger_error("html_options: output is an object of class '". get_class($output) ."' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error("html_options: output is an object of class '" . get_class($output) . "' without __toString() method", E_USER_NOTICE);
|
||||
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
$output = (string) $output;
|
||||
}
|
||||
|
||||
|
||||
if ($labels) {
|
||||
if ($label_ids) {
|
||||
$_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_', $name . '_' . $value));
|
||||
$_output .= '<label for="' . $_id . '">';
|
||||
} else {
|
||||
$_output .= '<label>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$name = smarty_function_escape_special_chars($name);
|
||||
$value = smarty_function_escape_special_chars($value);
|
||||
if ($escape) {
|
||||
$output = smarty_function_escape_special_chars($output);
|
||||
}
|
||||
|
||||
|
||||
$_output .= '<input type="checkbox" name="' . $name . '[]" value="' . $value . '"';
|
||||
|
||||
|
||||
if ($labels && $label_ids) {
|
||||
$_output .= ' id="' . $_id . '"';
|
||||
}
|
||||
|
||||
|
||||
if (is_array($selected)) {
|
||||
if (isset($selected[$value])) {
|
||||
$_output .= ' checked="checked"';
|
||||
|
@ -203,14 +225,13 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
|
|||
} elseif ($value === $selected) {
|
||||
$_output .= ' checked="checked"';
|
||||
}
|
||||
|
||||
|
||||
$_output .= $extra . ' />' . $output;
|
||||
if ($labels) {
|
||||
$_output .= '</label>';
|
||||
}
|
||||
|
||||
$_output .= $separator;
|
||||
|
||||
$_output .= $separator;
|
||||
|
||||
return $_output;
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,14 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {html_image} function plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: html_image<br>
|
||||
* Date: Feb 24, 2003<br>
|
||||
|
@ -23,21 +22,24 @@
|
|||
* - basedir - (optional) - base directory for absolute paths, default is environment variable DOCUMENT_ROOT
|
||||
* - path_prefix - prefix for path output (optional, default empty)
|
||||
* </pre>
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.image.php {html_image}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author credits to Duda <duda@big.hu>
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.image.php {html_image}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author credits to Duda <duda@big.hu>
|
||||
* @version 1.0
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
* @return string
|
||||
* @uses smarty_function_escape_special_chars()
|
||||
*
|
||||
* @throws SmartyException
|
||||
* @return string
|
||||
* @uses smarty_function_escape_special_chars()
|
||||
*/
|
||||
function smarty_function_html_image($params, $template)
|
||||
{
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
|
||||
|
||||
$alt = '';
|
||||
$file = '';
|
||||
$height = '';
|
||||
|
@ -47,7 +49,7 @@ function smarty_function_html_image($params, $template)
|
|||
$suffix = '';
|
||||
$path_prefix = '';
|
||||
$basedir = isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : '';
|
||||
foreach($params as $_key => $_val) {
|
||||
foreach ($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'file':
|
||||
case 'height':
|
||||
|
@ -63,7 +65,7 @@ function smarty_function_html_image($params, $template)
|
|||
$$_key = smarty_function_escape_special_chars($_val);
|
||||
} else {
|
||||
throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'link':
|
||||
|
@ -77,41 +79,42 @@ function smarty_function_html_image($params, $template)
|
|||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||
} else {
|
||||
throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($file)) {
|
||||
trigger_error("html_image: missing 'file' parameter", E_USER_NOTICE);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ($file[0] == '/') {
|
||||
$_image_path = $basedir . $file;
|
||||
} else {
|
||||
$_image_path = $file;
|
||||
}
|
||||
|
||||
|
||||
// strip file protocol
|
||||
if (stripos($params['file'], 'file://') === 0) {
|
||||
$params['file'] = substr($params['file'], 7);
|
||||
}
|
||||
|
||||
|
||||
$protocol = strpos($params['file'], '://');
|
||||
if ($protocol !== false) {
|
||||
$protocol = strtolower(substr($params['file'], 0, $protocol));
|
||||
}
|
||||
|
||||
|
||||
if (isset($template->smarty->security_policy)) {
|
||||
if ($protocol) {
|
||||
// remote resource (or php stream, …)
|
||||
if(!$template->smarty->security_policy->isTrustedUri($params['file'])) {
|
||||
if (!$template->smarty->security_policy->isTrustedUri($params['file'])) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// local file
|
||||
if(!$template->smarty->security_policy->isTrustedResourceDir($params['file'])) {
|
||||
if (!$template->smarty->security_policy->isTrustedResourceDir($_image_path)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -122,23 +125,26 @@ function smarty_function_html_image($params, $template)
|
|||
if (!$_image_data = @getimagesize($_image_path)) {
|
||||
if (!file_exists($_image_path)) {
|
||||
trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE);
|
||||
|
||||
return;
|
||||
} else if (!is_readable($_image_path)) {
|
||||
} elseif (!is_readable($_image_path)) {
|
||||
trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE);
|
||||
|
||||
return;
|
||||
} else {
|
||||
trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($params['width'])) {
|
||||
$width = $_image_data[0];
|
||||
}
|
||||
}
|
||||
if (!isset($params['height'])) {
|
||||
$height = $_image_data[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($params['dpi'])) {
|
||||
if (strstr($_SERVER['HTTP_USER_AGENT'], 'Mac')) {
|
||||
|
@ -147,13 +153,11 @@ function smarty_function_html_image($params, $template)
|
|||
$dpi_default = 72;
|
||||
} else {
|
||||
$dpi_default = 96;
|
||||
}
|
||||
}
|
||||
$_resize = $dpi_default / $params['dpi'];
|
||||
$width = round($width * $_resize);
|
||||
$height = round($height * $_resize);
|
||||
}
|
||||
}
|
||||
|
||||
return $prefix . '<img src="' . $path_prefix . $file . '" alt="' . $alt . '" width="' . $width . '" height="' . $height . '"' . $extra . ' />' . $suffix;
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {html_options} function plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: html_options<br>
|
||||
* Purpose: Prints the list of <option> tags generated from
|
||||
|
@ -23,17 +22,18 @@
|
|||
* - id (optional) - string default not set
|
||||
* - class (optional) - string default not set
|
||||
* </pre>
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.options.php {html_image}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Ralf Strehle (minor optimization) <ralf dot strehle at yahoo dot de>
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
* @return string
|
||||
* @uses smarty_function_escape_special_chars()
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.options.php {html_image}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Ralf Strehle (minor optimization) <ralf dot strehle at yahoo dot de>
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string
|
||||
* @uses smarty_function_escape_special_chars()
|
||||
*/
|
||||
function smarty_function_html_options($params, $template)
|
||||
function smarty_function_html_options($params)
|
||||
{
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
|
||||
|
@ -72,7 +72,7 @@ function smarty_function_html_options($params, $template)
|
|||
if (method_exists($_sel, "__toString")) {
|
||||
$_sel = smarty_function_escape_special_chars((string) $_sel->__toString());
|
||||
} else {
|
||||
trigger_error("html_options: selected attribute contains an object of class '". get_class($_sel) ."' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error("html_options: selected attribute contains an object of class '" . get_class($_sel) . "' without __toString() method", E_USER_NOTICE);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
|
@ -84,25 +84,44 @@ function smarty_function_html_options($params, $template)
|
|||
if (method_exists($_val, "__toString")) {
|
||||
$selected = smarty_function_escape_special_chars((string) $_val->__toString());
|
||||
} else {
|
||||
trigger_error("html_options: selected attribute is an object of class '". get_class($_val) ."' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error("html_options: selected attribute is an object of class '" . get_class($_val) . "' without __toString() method", E_USER_NOTICE);
|
||||
}
|
||||
} else {
|
||||
$selected = smarty_function_escape_special_chars((string) $_val);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'strict':
|
||||
break;
|
||||
|
||||
case 'disabled':
|
||||
case 'readonly':
|
||||
if (!empty($params['strict'])) {
|
||||
if (!is_scalar($_val)) {
|
||||
trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute", E_USER_NOTICE);
|
||||
}
|
||||
|
||||
if ($_val === true || $_val === $_key) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"';
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
// omit break; to fall through!
|
||||
|
||||
default:
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||
} else {
|
||||
trigger_error("html_options: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($options) && !isset($values)) {
|
||||
/* raise error here? */
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -117,14 +136,14 @@ function smarty_function_html_options($params, $template)
|
|||
foreach ($values as $_i => $_key) {
|
||||
$_val = isset($output[$_i]) ? $output[$_i] : '';
|
||||
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected, $id, $class, $_idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($name)) {
|
||||
$_html_class = !empty($class) ? ' class="'.$class.'"' : '';
|
||||
$_html_id = !empty($id) ? ' id="'.$id.'"' : '';
|
||||
$_html_class = !empty($class) ? ' class="' . $class . '"' : '';
|
||||
$_html_id = !empty($id) ? ' id="' . $id . '"' : '';
|
||||
$_html_result = '<select name="' . $name . '"' . $_html_class . $_html_id . $extra . '>' . "\n" . $_html_result . '</select>' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
return $_html_result;
|
||||
}
|
||||
|
@ -141,36 +160,37 @@ function smarty_function_html_options_optoutput($key, $value, $selected, $id, $c
|
|||
} elseif ($_key === $selected) {
|
||||
$_html_result .= ' selected="selected"';
|
||||
}
|
||||
$_html_class = !empty($class) ? ' class="'.$class.' option"' : '';
|
||||
$_html_id = !empty($id) ? ' id="'.$id.'-'.$idx.'"' : '';
|
||||
$_html_class = !empty($class) ? ' class="' . $class . ' option"' : '';
|
||||
$_html_id = !empty($id) ? ' id="' . $id . '-' . $idx . '"' : '';
|
||||
if (is_object($value)) {
|
||||
if (method_exists($value, "__toString")) {
|
||||
$value = smarty_function_escape_special_chars((string) $value->__toString());
|
||||
} else {
|
||||
trigger_error("html_options: value is an object of class '". get_class($value) ."' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error("html_options: value is an object of class '" . get_class($value) . "' without __toString() method", E_USER_NOTICE);
|
||||
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
$value = smarty_function_escape_special_chars((string) $value);
|
||||
}
|
||||
$_html_result .= $_html_class . $_html_id . '>' . $value . '</option>' . "\n";
|
||||
$idx++;
|
||||
$idx ++;
|
||||
} else {
|
||||
$_idx = 0;
|
||||
$_html_result = smarty_function_html_options_optgroup($key, $value, $selected, !empty($id) ? ($id.'-'.$idx) : null, $class, $_idx);
|
||||
$idx++;
|
||||
$_html_result = smarty_function_html_options_optgroup($key, $value, $selected, !empty($id) ? ($id . '-' . $idx) : null, $class, $_idx);
|
||||
$idx ++;
|
||||
}
|
||||
|
||||
return $_html_result;
|
||||
}
|
||||
}
|
||||
|
||||
function smarty_function_html_options_optgroup($key, $values, $selected, $id, $class, &$idx)
|
||||
{
|
||||
$optgroup_html = '<optgroup label="' . smarty_function_escape_special_chars($key) . '">' . "\n";
|
||||
foreach ($values as $key => $value) {
|
||||
$optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected, $id, $class, $idx);
|
||||
}
|
||||
}
|
||||
$optgroup_html .= "</optgroup>\n";
|
||||
return $optgroup_html;
|
||||
}
|
||||
|
||||
?>
|
||||
return $optgroup_html;
|
||||
}
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {html_radios} function plugin
|
||||
*
|
||||
* File: function.html_radios.php<br>
|
||||
* Type: function<br>
|
||||
* Name: html_radios<br>
|
||||
|
@ -31,16 +30,18 @@
|
|||
* {html_radios values=$ids name='box' separator='<br>' output=$names}
|
||||
* {html_radios values=$ids checked=$checked separator='<br>' output=$names}
|
||||
* </pre>
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios}
|
||||
* (Smarty online manual)
|
||||
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
|
||||
* @author credits to Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios}
|
||||
* (Smarty online manual)
|
||||
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
|
||||
* @author credits to Monte Ohrt <monte at ohrt dot com>
|
||||
* @version 1.0
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
* @return string
|
||||
* @uses smarty_function_escape_special_chars()
|
||||
*
|
||||
* @return string
|
||||
* @uses smarty_function_escape_special_chars()
|
||||
*/
|
||||
function smarty_function_html_radios($params, $template)
|
||||
{
|
||||
|
@ -57,7 +58,7 @@ function smarty_function_html_radios($params, $template)
|
|||
$output = null;
|
||||
$extra = '';
|
||||
|
||||
foreach($params as $_key => $_val) {
|
||||
foreach ($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'name':
|
||||
case 'separator':
|
||||
|
@ -72,11 +73,11 @@ function smarty_function_html_radios($params, $template)
|
|||
if (method_exists($_val, "__toString")) {
|
||||
$selected = smarty_function_escape_special_chars((string) $_val->__toString());
|
||||
} else {
|
||||
trigger_error("html_radios: selected attribute is an object of class '". get_class($_val) ."' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error("html_radios: selected attribute is an object of class '" . get_class($_val) . "' without __toString() method", E_USER_NOTICE);
|
||||
}
|
||||
} else {
|
||||
$selected = (string) $_val;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'escape':
|
||||
|
@ -102,18 +103,37 @@ function smarty_function_html_radios($params, $template)
|
|||
case 'assign':
|
||||
break;
|
||||
|
||||
case 'strict':
|
||||
break;
|
||||
|
||||
case 'disabled':
|
||||
case 'readonly':
|
||||
if (!empty($params['strict'])) {
|
||||
if (!is_scalar($_val)) {
|
||||
trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute", E_USER_NOTICE);
|
||||
}
|
||||
|
||||
if ($_val === true || $_val === $_key) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"';
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
// omit break; to fall through!
|
||||
|
||||
default:
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||
} else {
|
||||
trigger_error("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($options) && !isset($values)) {
|
||||
/* raise error here? */
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -127,57 +147,59 @@ function smarty_function_html_radios($params, $template)
|
|||
foreach ($values as $_i => $_key) {
|
||||
$_val = isset($output[$_i]) ? $output[$_i] : '';
|
||||
$_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids, $escape);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($params['assign'])) {
|
||||
$template->assign($params['assign'], $_html_result);
|
||||
} else {
|
||||
return implode("\n", $_html_result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids, $escape)
|
||||
{
|
||||
$_output = '';
|
||||
|
||||
|
||||
if (is_object($value)) {
|
||||
if (method_exists($value, "__toString")) {
|
||||
$value = (string) $value->__toString();
|
||||
} else {
|
||||
trigger_error("html_options: value is an object of class '". get_class($value) ."' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error("html_options: value is an object of class '" . get_class($value) . "' without __toString() method", E_USER_NOTICE);
|
||||
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
$value = (string) $value;
|
||||
}
|
||||
|
||||
|
||||
if (is_object($output)) {
|
||||
if (method_exists($output, "__toString")) {
|
||||
$output = (string) $output->__toString();
|
||||
} else {
|
||||
trigger_error("html_options: output is an object of class '". get_class($output) ."' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error("html_options: output is an object of class '" . get_class($output) . "' without __toString() method", E_USER_NOTICE);
|
||||
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
$output = (string) $output;
|
||||
}
|
||||
|
||||
|
||||
if ($labels) {
|
||||
if ($label_ids) {
|
||||
$_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_', $name . '_' . $value));
|
||||
$_output .= '<label for="' . $_id . '">';
|
||||
} else {
|
||||
$_output .= '<label>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$name = smarty_function_escape_special_chars($name);
|
||||
$value = smarty_function_escape_special_chars($value);
|
||||
if ($escape) {
|
||||
$output = smarty_function_escape_special_chars($output);
|
||||
}
|
||||
|
||||
|
||||
$_output .= '<input type="radio" name="' . $name . '" value="' . $value . '"';
|
||||
|
||||
if ($labels && $label_ids) {
|
||||
|
@ -187,14 +209,13 @@ function smarty_function_html_radios_output($name, $value, $output, $selected, $
|
|||
if ($value === $selected) {
|
||||
$_output .= ' checked="checked"';
|
||||
}
|
||||
|
||||
|
||||
$_output .= $extra . ' />' . $output;
|
||||
if ($labels) {
|
||||
$_output .= '</label>';
|
||||
}
|
||||
|
||||
$_output .= $separator;
|
||||
return $_output;
|
||||
}
|
||||
|
||||
?>
|
||||
$_output .= $separator;
|
||||
|
||||
return $_output;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
|
@ -17,11 +17,9 @@ require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
|||
|
||||
/**
|
||||
* Smarty {html_select_date} plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: html_select_date<br>
|
||||
* Purpose: Prints the dropdowns for date selection.
|
||||
*
|
||||
* ChangeLog:
|
||||
* <pre>
|
||||
* - 1.0 initial release
|
||||
|
@ -37,21 +35,22 @@ require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
|||
* dropdown to include given date unless explicitly set (Monte)
|
||||
* - 1.3.4 fix behaviour of 0000-00-00 00:00:00 dates to match that
|
||||
* of 0000-00-00 dates (cybot, boots)
|
||||
* - 2.0 complete rewrite for performance,
|
||||
* - 2.0 complete rewrite for performance,
|
||||
* added attributes month_names, *_id
|
||||
* </pre>
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.select.date.php {html_select_date}
|
||||
* (Smarty online manual)
|
||||
* @version 2.0
|
||||
* @author Andrei Zmievski
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Rodney Rehm
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
* @return string
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.select.date.php {html_select_date}
|
||||
* (Smarty online manual)
|
||||
* @version 2.0
|
||||
* @author Andrei Zmievski
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Rodney Rehm
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_function_html_select_date($params, $template)
|
||||
function smarty_function_html_select_date($params)
|
||||
{
|
||||
// generate timestamps used for month names only
|
||||
static $_month_timestamps = null;
|
||||
|
@ -59,7 +58,7 @@ function smarty_function_html_select_date($params, $template)
|
|||
if ($_month_timestamps === null) {
|
||||
$_current_year = date('Y');
|
||||
$_month_timestamps = array();
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
for ($i = 1; $i <= 12; $i ++) {
|
||||
$_month_timestamps[$i] = mktime(0, 0, 0, $i, 1, 2000);
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +119,7 @@ function smarty_function_html_select_date($params, $template)
|
|||
$time = smarty_make_timestamp($_value);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'month_names':
|
||||
if (is_array($_value) && count($_value) == 12) {
|
||||
$$_key = $_value;
|
||||
|
@ -128,7 +127,7 @@ function smarty_function_html_select_date($params, $template)
|
|||
trigger_error("html_select_date: month_names must be an array of 12 strings", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'prefix':
|
||||
case 'field_array':
|
||||
case 'start_year':
|
||||
|
@ -155,7 +154,7 @@ function smarty_function_html_select_date($params, $template)
|
|||
case 'month_id':
|
||||
case 'day_id':
|
||||
case 'year_id':
|
||||
$$_key = (string)$_value;
|
||||
$$_key = (string) $_value;
|
||||
break;
|
||||
|
||||
case 'display_days':
|
||||
|
@ -163,7 +162,7 @@ function smarty_function_html_select_date($params, $template)
|
|||
case 'display_years':
|
||||
case 'year_as_text':
|
||||
case 'reverse_years':
|
||||
$$_key = (bool)$_value;
|
||||
$$_key = (bool) $_value;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -171,32 +170,30 @@ function smarty_function_html_select_date($params, $template)
|
|||
$extra_attrs .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_value) . '"';
|
||||
} else {
|
||||
trigger_error("html_select_date: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Note: date() is faster than strftime()
|
||||
// Note: explode(date()) is faster than date() date() date()
|
||||
if (isset($params['time']) && is_array($params['time'])) {
|
||||
if (isset($params['time'][$prefix . 'Year'])) {
|
||||
// $_REQUEST[$field_array] given
|
||||
foreach (array('Y' => 'Year', 'm' => 'Month', 'd' => 'Day') as $_elementKey => $_elementName) {
|
||||
foreach (array('Y' => 'Year', 'm' => 'Month', 'd' => 'Day') as $_elementKey => $_elementName) {
|
||||
$_variableName = '_' . strtolower($_elementName);
|
||||
$$_variableName = isset($params['time'][$prefix . $_elementName])
|
||||
? $params['time'][$prefix . $_elementName]
|
||||
: date($_elementKey);
|
||||
}
|
||||
$time = mktime(0, 0, 0, $_month, $_day, $_year);
|
||||
} elseif (isset($params['time'][$field_array][$prefix . 'Year'])) {
|
||||
// $_REQUEST given
|
||||
foreach (array('Y' => 'Year', 'm' => 'Month', 'd' => 'Day') as $_elementKey => $_elementName) {
|
||||
foreach (array('Y' => 'Year', 'm' => 'Month', 'd' => 'Day') as $_elementKey => $_elementName) {
|
||||
$_variableName = '_' . strtolower($_elementName);
|
||||
$$_variableName = isset($params['time'][$field_array][$prefix . $_elementName])
|
||||
? $params['time'][$field_array][$prefix . $_elementName]
|
||||
: date($_elementKey);
|
||||
}
|
||||
$time = mktime(0, 0, 0, $_month, $_day, $_year);
|
||||
} else {
|
||||
// no date found, use NOW
|
||||
list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d'));
|
||||
|
@ -217,13 +214,13 @@ function smarty_function_html_select_date($params, $template)
|
|||
$key .= '_year';
|
||||
$t = $$key;
|
||||
if ($t === null) {
|
||||
$$key = (int)$_current_year;
|
||||
} else if ($t[0] == '+') {
|
||||
$$key = (int)($_current_year + trim(substr($t, 1)));
|
||||
} else if ($t[0] == '-') {
|
||||
$$key = (int)($_current_year - trim(substr($t, 1)));
|
||||
$$key = (int) $_current_year;
|
||||
} elseif ($t[0] == '+') {
|
||||
$$key = (int) ($_current_year + (int)trim(substr($t, 1)));
|
||||
} elseif ($t[0] == '-') {
|
||||
$$key = (int) ($_current_year - (int)trim(substr($t, 1)));
|
||||
} else {
|
||||
$$key = (int)$$key;
|
||||
$$key = (int) $$key;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -236,73 +233,71 @@ function smarty_function_html_select_date($params, $template)
|
|||
|
||||
// generate year <select> or <input>
|
||||
if ($display_years) {
|
||||
$_html_years = '';
|
||||
$_extra = '';
|
||||
$_name = $field_array ? ($field_array . '[' . $prefix . 'Year]') : ($prefix . 'Year');
|
||||
if ($all_extra) {
|
||||
$_extra .= ' ' . $all_extra;
|
||||
}
|
||||
}
|
||||
if ($year_extra) {
|
||||
$_extra .= ' ' . $year_extra;
|
||||
}
|
||||
|
||||
|
||||
if ($year_as_text) {
|
||||
$_html_years = '<input type="text" name="' . $_name . '" value="' . $_year . '" size="4" maxlength="4"' . $_extra . $extra_attrs . ' />';
|
||||
} else {
|
||||
$_html_years = '<select name="' . $_name . '"';
|
||||
if ($year_id !== null || $all_id !== null) {
|
||||
$_html_years .= ' id="' . smarty_function_escape_special_chars(
|
||||
$year_id !== null ? ( $year_id ? $year_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
|
||||
) . '"';
|
||||
$_html_years .= ' id="' . smarty_function_escape_special_chars(
|
||||
$year_id !== null ? ($year_id ? $year_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
}
|
||||
if ($year_size) {
|
||||
$_html_years .= ' size="' . $year_size . '"';
|
||||
}
|
||||
$_html_years .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
|
||||
if (isset($year_empty) || isset($all_empty)) {
|
||||
$_html_years .= '<option value="">' . ( isset($year_empty) ? $year_empty : $all_empty ) . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
$op = $start_year > $end_year ? -1 : 1;
|
||||
for ($i=$start_year; $op > 0 ? $i <= $end_year : $i >= $end_year; $i += $op) {
|
||||
$_html_years .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
|
||||
if (isset($year_empty) || isset($all_empty)) {
|
||||
$_html_years .= '<option value="">' . (isset($year_empty) ? $year_empty : $all_empty) . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
$op = $start_year > $end_year ? - 1 : 1;
|
||||
for ($i = $start_year; $op > 0 ? $i <= $end_year : $i >= $end_year; $i += $op) {
|
||||
$_html_years .= '<option value="' . $i . '"'
|
||||
. ($_year == $i ? ' selected="selected"' : '')
|
||||
. '>' . $i . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
|
||||
$_html_years .= '</select>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// generate month <select> or <input>
|
||||
if ($display_months) {
|
||||
$_html_month = '';
|
||||
$_extra = '';
|
||||
$_name = $field_array ? ($field_array . '[' . $prefix . 'Month]') : ($prefix . 'Month');
|
||||
if ($all_extra) {
|
||||
$_extra .= ' ' . $all_extra;
|
||||
}
|
||||
}
|
||||
if ($month_extra) {
|
||||
$_extra .= ' ' . $month_extra;
|
||||
}
|
||||
|
||||
|
||||
$_html_months = '<select name="' . $_name . '"';
|
||||
if ($month_id !== null || $all_id !== null) {
|
||||
$_html_months .= ' id="' . smarty_function_escape_special_chars(
|
||||
$month_id !== null ? ( $month_id ? $month_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
|
||||
) . '"';
|
||||
$_html_months .= ' id="' . smarty_function_escape_special_chars(
|
||||
$month_id !== null ? ($month_id ? $month_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
}
|
||||
if ($month_size) {
|
||||
$_html_months .= ' size="' . $month_size . '"';
|
||||
}
|
||||
$_html_months .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
|
||||
if (isset($month_empty) || isset($all_empty)) {
|
||||
$_html_months .= '<option value="">' . ( isset($month_empty) ? $month_empty : $all_empty ) . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$_html_months .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
|
||||
if (isset($month_empty) || isset($all_empty)) {
|
||||
$_html_months .= '<option value="">' . (isset($month_empty) ? $month_empty : $all_empty) . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= 12; $i ++) {
|
||||
$_val = sprintf('%02d', $i);
|
||||
$_text = isset($month_names) ? smarty_function_escape_special_chars($month_names[$i]) : ($month_format == "%m" ? $_val : strftime($month_format, $_month_timestamps[$i]));
|
||||
$_value = $month_value_format == "%m" ? $_val : strftime($month_value_format, $_month_timestamps[$i]);
|
||||
|
@ -310,52 +305,51 @@ function smarty_function_html_select_date($params, $template)
|
|||
. ($_val == $_month ? ' selected="selected"' : '')
|
||||
. '>' . $_text . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
|
||||
$_html_months .= '</select>';
|
||||
}
|
||||
|
||||
|
||||
// generate day <select> or <input>
|
||||
if ($display_days) {
|
||||
$_html_day = '';
|
||||
$_extra = '';
|
||||
$_name = $field_array ? ($field_array . '[' . $prefix . 'Day]') : ($prefix . 'Day');
|
||||
if ($all_extra) {
|
||||
$_extra .= ' ' . $all_extra;
|
||||
}
|
||||
}
|
||||
if ($day_extra) {
|
||||
$_extra .= ' ' . $day_extra;
|
||||
}
|
||||
|
||||
|
||||
$_html_days = '<select name="' . $_name . '"';
|
||||
if ($day_id !== null || $all_id !== null) {
|
||||
$_html_days .= ' id="' . smarty_function_escape_special_chars(
|
||||
$day_id !== null ? ( $day_id ? $day_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
|
||||
) . '"';
|
||||
$_html_days .= ' id="' . smarty_function_escape_special_chars(
|
||||
$day_id !== null ? ($day_id ? $day_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
}
|
||||
if ($day_size) {
|
||||
$_html_days .= ' size="' . $day_size . '"';
|
||||
}
|
||||
$_html_days .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
|
||||
if (isset($day_empty) || isset($all_empty)) {
|
||||
$_html_days .= '<option value="">' . ( isset($day_empty) ? $day_empty : $all_empty ) . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= 31; $i++) {
|
||||
$_html_days .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
|
||||
if (isset($day_empty) || isset($all_empty)) {
|
||||
$_html_days .= '<option value="">' . (isset($day_empty) ? $day_empty : $all_empty) . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= 31; $i ++) {
|
||||
$_val = sprintf('%02d', $i);
|
||||
$_text = $day_format == '%02d' ? $_val : sprintf($day_format, $i);
|
||||
$_value = $day_value_format == '%02d' ? $_val : sprintf($day_value_format, $i);
|
||||
$_value = $day_value_format == '%02d' ? $_val : sprintf($day_value_format, $i);
|
||||
$_html_days .= '<option value="' . $_value . '"'
|
||||
. ($_val == $_day ? ' selected="selected"' : '')
|
||||
. '>' . $_text . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
|
||||
$_html_days .= '</select>';
|
||||
}
|
||||
|
||||
// order the fields for output
|
||||
$_html = '';
|
||||
for ($i=0; $i <= 2; $i++) {
|
||||
for ($i = 0; $i <= 2; $i ++) {
|
||||
switch ($field_order[$i]) {
|
||||
case 'Y':
|
||||
case 'y':
|
||||
|
@ -365,8 +359,8 @@ function smarty_function_html_select_date($params, $template)
|
|||
}
|
||||
$_html .= $_html_years;
|
||||
}
|
||||
break;
|
||||
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
case 'M':
|
||||
if (isset($_html_months)) {
|
||||
|
@ -375,8 +369,8 @@ function smarty_function_html_select_date($params, $template)
|
|||
}
|
||||
$_html .= $_html_months;
|
||||
}
|
||||
break;
|
||||
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
case 'D':
|
||||
if (isset($_html_days)) {
|
||||
|
@ -385,10 +379,9 @@ function smarty_function_html_select_date($params, $template)
|
|||
}
|
||||
$_html .= $_html_days;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $_html;
|
||||
}
|
||||
|
||||
?>
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
|
@ -17,21 +17,21 @@ require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
|||
|
||||
/**
|
||||
* Smarty {html_select_time} function plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: html_select_time<br>
|
||||
* Purpose: Prints the dropdowns for time selection
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.select.time.php {html_select_time}
|
||||
* (Smarty online manual)
|
||||
* @author Roberto Berto <roberto@berto.net>
|
||||
* @author Monte Ohrt <monte AT ohrt DOT com>
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.select.time.php {html_select_time}
|
||||
* (Smarty online manual)
|
||||
* @author Roberto Berto <roberto@berto.net>
|
||||
* @author Monte Ohrt <monte AT ohrt DOT com>
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string
|
||||
* @uses smarty_make_timestamp()
|
||||
* @uses smarty_make_timestamp()
|
||||
*/
|
||||
function smarty_function_html_select_time($params, $template)
|
||||
function smarty_function_html_select_time($params)
|
||||
{
|
||||
$prefix = "Time_";
|
||||
$field_array = null;
|
||||
|
@ -117,7 +117,7 @@ function smarty_function_html_select_time($params, $template)
|
|||
case 'minute_value_format':
|
||||
case 'second_format':
|
||||
case 'second_value_format':
|
||||
$$_key = (string)$_value;
|
||||
$$_key = (string) $_value;
|
||||
break;
|
||||
|
||||
case 'display_hours':
|
||||
|
@ -125,7 +125,7 @@ function smarty_function_html_select_time($params, $template)
|
|||
case 'display_seconds':
|
||||
case 'display_meridian':
|
||||
case 'use_24_hours':
|
||||
$$_key = (bool)$_value;
|
||||
$$_key = (bool) $_value;
|
||||
break;
|
||||
|
||||
case 'minute_interval':
|
||||
|
@ -135,7 +135,7 @@ function smarty_function_html_select_time($params, $template)
|
|||
case 'minute_size':
|
||||
case 'second_size':
|
||||
case 'meridian_size':
|
||||
$$_key = (int)$_value;
|
||||
$$_key = (int) $_value;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -151,7 +151,7 @@ function smarty_function_html_select_time($params, $template)
|
|||
if (isset($params['time']) && is_array($params['time'])) {
|
||||
if (isset($params['time'][$prefix . 'Hour'])) {
|
||||
// $_REQUEST[$field_array] given
|
||||
foreach (array('H' => 'Hour', 'i' => 'Minute', 's' => 'Second') as $_elementKey => $_elementName) {
|
||||
foreach (array('H' => 'Hour', 'i' => 'Minute', 's' => 'Second') as $_elementKey => $_elementName) {
|
||||
$_variableName = '_' . strtolower($_elementName);
|
||||
$$_variableName = isset($params['time'][$prefix . $_elementName])
|
||||
? $params['time'][$prefix . $_elementName]
|
||||
|
@ -160,11 +160,11 @@ function smarty_function_html_select_time($params, $template)
|
|||
$_meridian = isset($params['time'][$prefix . 'Meridian'])
|
||||
? (' ' . $params['time'][$prefix . 'Meridian'])
|
||||
: '';
|
||||
$time = strtotime( $_hour . ':' . $_minute . ':' . $_second . $_meridian );
|
||||
$time = strtotime($_hour . ':' . $_minute . ':' . $_second . $_meridian);
|
||||
list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time));
|
||||
} elseif (isset($params['time'][$field_array][$prefix . 'Hour'])) {
|
||||
// $_REQUEST given
|
||||
foreach (array('H' => 'Hour', 'i' => 'Minute', 's' => 'Second') as $_elementKey => $_elementName) {
|
||||
foreach (array('H' => 'Hour', 'i' => 'Minute', 's' => 'Second') as $_elementKey => $_elementName) {
|
||||
$_variableName = '_' . strtolower($_elementName);
|
||||
$$_variableName = isset($params['time'][$field_array][$prefix . $_elementName])
|
||||
? $params['time'][$field_array][$prefix . $_elementName]
|
||||
|
@ -173,7 +173,7 @@ function smarty_function_html_select_time($params, $template)
|
|||
$_meridian = isset($params['time'][$field_array][$prefix . 'Meridian'])
|
||||
? (' ' . $params['time'][$field_array][$prefix . 'Meridian'])
|
||||
: '';
|
||||
$time = strtotime( $_hour . ':' . $_minute . ':' . $_second . $_meridian );
|
||||
$time = strtotime($_hour . ':' . $_minute . ':' . $_second . $_meridian);
|
||||
list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time));
|
||||
} else {
|
||||
// no date found, use NOW
|
||||
|
@ -204,8 +204,8 @@ function smarty_function_html_select_time($params, $template)
|
|||
$_html_hours = '<select name="' . $_name . '"';
|
||||
if ($hour_id !== null || $all_id !== null) {
|
||||
$_html_hours .= ' id="' . smarty_function_escape_special_chars(
|
||||
$hour_id !== null ? ( $hour_id ? $hour_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
|
||||
) . '"';
|
||||
$hour_id !== null ? ($hour_id ? $hour_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
}
|
||||
if ($hour_size) {
|
||||
$_html_hours .= ' size="' . $hour_size . '"';
|
||||
|
@ -213,12 +213,12 @@ function smarty_function_html_select_time($params, $template)
|
|||
$_html_hours .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
|
||||
if (isset($hour_empty) || isset($all_empty)) {
|
||||
$_html_hours .= '<option value="">' . ( isset($hour_empty) ? $hour_empty : $all_empty ) . '</option>' . $option_separator;
|
||||
$_html_hours .= '<option value="">' . (isset($hour_empty) ? $hour_empty : $all_empty) . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
$start = $use_24_hours ? 0 : 1;
|
||||
$end = $use_24_hours ? 23 : 12;
|
||||
for ($i=$start; $i <= $end; $i++) {
|
||||
for ($i = $start; $i <= $end; $i ++) {
|
||||
$_val = sprintf('%02d', $i);
|
||||
$_text = $hour_format == '%02d' ? $_val : sprintf($hour_format, $i);
|
||||
$_value = $hour_value_format == '%02d' ? $_val : sprintf($hour_value_format, $i);
|
||||
|
@ -226,7 +226,7 @@ function smarty_function_html_select_time($params, $template)
|
|||
if (!$use_24_hours) {
|
||||
$_hour12 = $_hour == 0
|
||||
? 12
|
||||
: ($_hour <= 12 ? $_hour : $_hour -12);
|
||||
: ($_hour <= 12 ? $_hour : $_hour - 12);
|
||||
}
|
||||
|
||||
$selected = $_hour !== null ? ($use_24_hours ? $_hour == $_val : $_hour12 == $_val) : null;
|
||||
|
@ -253,8 +253,8 @@ function smarty_function_html_select_time($params, $template)
|
|||
$_html_minutes = '<select name="' . $_name . '"';
|
||||
if ($minute_id !== null || $all_id !== null) {
|
||||
$_html_minutes .= ' id="' . smarty_function_escape_special_chars(
|
||||
$minute_id !== null ? ( $minute_id ? $minute_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
|
||||
) . '"';
|
||||
$minute_id !== null ? ($minute_id ? $minute_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
}
|
||||
if ($minute_size) {
|
||||
$_html_minutes .= ' size="' . $minute_size . '"';
|
||||
|
@ -262,11 +262,11 @@ function smarty_function_html_select_time($params, $template)
|
|||
$_html_minutes .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
|
||||
if (isset($minute_empty) || isset($all_empty)) {
|
||||
$_html_minutes .= '<option value="">' . ( isset($minute_empty) ? $minute_empty : $all_empty ) . '</option>' . $option_separator;
|
||||
$_html_minutes .= '<option value="">' . (isset($minute_empty) ? $minute_empty : $all_empty) . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
$selected = $_minute !== null ? ($_minute - $_minute % $minute_interval) : null;
|
||||
for ($i=0; $i <= 59; $i += $minute_interval) {
|
||||
for ($i = 0; $i <= 59; $i += $minute_interval) {
|
||||
$_val = sprintf('%02d', $i);
|
||||
$_text = $minute_format == '%02d' ? $_val : sprintf($minute_format, $i);
|
||||
$_value = $minute_value_format == '%02d' ? $_val : sprintf($minute_value_format, $i);
|
||||
|
@ -293,8 +293,8 @@ function smarty_function_html_select_time($params, $template)
|
|||
$_html_seconds = '<select name="' . $_name . '"';
|
||||
if ($second_id !== null || $all_id !== null) {
|
||||
$_html_seconds .= ' id="' . smarty_function_escape_special_chars(
|
||||
$second_id !== null ? ( $second_id ? $second_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
|
||||
) . '"';
|
||||
$second_id !== null ? ($second_id ? $second_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
}
|
||||
if ($second_size) {
|
||||
$_html_seconds .= ' size="' . $second_size . '"';
|
||||
|
@ -302,11 +302,11 @@ function smarty_function_html_select_time($params, $template)
|
|||
$_html_seconds .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
|
||||
if (isset($second_empty) || isset($all_empty)) {
|
||||
$_html_seconds .= '<option value="">' . ( isset($second_empty) ? $second_empty : $all_empty ) . '</option>' . $option_separator;
|
||||
$_html_seconds .= '<option value="">' . (isset($second_empty) ? $second_empty : $all_empty) . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
$selected = $_second !== null ? ($_second - $_second % $second_interval) : null;
|
||||
for ($i=0; $i <= 59; $i += $second_interval) {
|
||||
for ($i = 0; $i <= 59; $i += $second_interval) {
|
||||
$_val = sprintf('%02d', $i);
|
||||
$_text = $second_format == '%02d' ? $_val : sprintf($second_format, $i);
|
||||
$_value = $second_value_format == '%02d' ? $_val : sprintf($second_value_format, $i);
|
||||
|
@ -333,8 +333,8 @@ function smarty_function_html_select_time($params, $template)
|
|||
$_html_meridian = '<select name="' . $_name . '"';
|
||||
if ($meridian_id !== null || $all_id !== null) {
|
||||
$_html_meridian .= ' id="' . smarty_function_escape_special_chars(
|
||||
$meridian_id !== null ? ( $meridian_id ? $meridian_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
|
||||
) . '"';
|
||||
$meridian_id !== null ? ($meridian_id ? $meridian_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
}
|
||||
if ($meridian_size) {
|
||||
$_html_meridian .= ' size="' . $meridian_size . '"';
|
||||
|
@ -342,11 +342,11 @@ function smarty_function_html_select_time($params, $template)
|
|||
$_html_meridian .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
|
||||
if (isset($meridian_empty) || isset($all_empty)) {
|
||||
$_html_meridian .= '<option value="">' . ( isset($meridian_empty) ? $meridian_empty : $all_empty ) . '</option>' . $option_separator;
|
||||
$_html_meridian .= '<option value="">' . (isset($meridian_empty) ? $meridian_empty : $all_empty) . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
$_html_meridian .= '<option value="am"'. ($_hour < 12 ? ' selected="selected"' : '') .'>AM</option>' . $option_separator
|
||||
. '<option value="pm"'. ($_hour < 12 ? '' : ' selected="selected"') .'>PM</option>' . $option_separator
|
||||
$_html_meridian .= '<option value="am"' . ($_hour > 0 && $_hour < 12 ? ' selected="selected"' : '') . '>AM</option>' . $option_separator
|
||||
. '<option value="pm"' . ($_hour < 12 ? '' : ' selected="selected"') . '>PM</option>' . $option_separator
|
||||
. '</select>';
|
||||
}
|
||||
|
||||
|
@ -362,5 +362,3 @@ function smarty_function_html_select_time($params, $template)
|
|||
|
||||
return $_html;
|
||||
}
|
||||
|
||||
?>
|
|
@ -2,13 +2,12 @@
|
|||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {html_table} function plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: html_table<br>
|
||||
* Date: Feb 17, 2003<br>
|
||||
|
@ -37,17 +36,18 @@
|
|||
* {table loop=$data cols="first,second,third" tr_attr=$colors}
|
||||
* </pre>
|
||||
*
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author credit to Messju Mohr <messju at lammfellpuschen dot de>
|
||||
* @author credit to boots <boots dot smarty at yahoo dot com>
|
||||
* @version 1.1
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.table.php {html_table}
|
||||
* (Smarty online manual)
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author credit to Messju Mohr <messju at lammfellpuschen dot de>
|
||||
* @author credit to boots <boots dot smarty at yahoo dot com>
|
||||
* @version 1.1
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.table.php {html_table}
|
||||
* (Smarty online manual)
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_function_html_table($params, $template)
|
||||
function smarty_function_html_table($params)
|
||||
{
|
||||
$table_attr = 'border="1"';
|
||||
$tr_attr = '';
|
||||
|
@ -63,14 +63,15 @@ function smarty_function_html_table($params, $template)
|
|||
$loop = null;
|
||||
|
||||
if (!isset($params['loop'])) {
|
||||
trigger_error("html_table: missing 'loop' parameter",E_USER_WARNING);
|
||||
trigger_error("html_table: missing 'loop' parameter", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($params as $_key => $_value) {
|
||||
switch ($_key) {
|
||||
case 'loop':
|
||||
$$_key = (array)$_value;
|
||||
$$_key = (array) $_value;
|
||||
break;
|
||||
|
||||
case 'cols':
|
||||
|
@ -81,14 +82,14 @@ function smarty_function_html_table($params, $template)
|
|||
$cols = explode(',', $_value);
|
||||
$cols_count = count($cols);
|
||||
} elseif (!empty($_value)) {
|
||||
$cols_count = (int)$_value;
|
||||
$cols_count = (int) $_value;
|
||||
} else {
|
||||
$cols_count = $cols;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'rows':
|
||||
$$_key = (int)$_value;
|
||||
$$_key = (int) $_value;
|
||||
break;
|
||||
|
||||
case 'table_attr':
|
||||
|
@ -97,7 +98,7 @@ function smarty_function_html_table($params, $template)
|
|||
case 'vdir':
|
||||
case 'inner':
|
||||
case 'caption':
|
||||
$$_key = (string)$_value;
|
||||
$$_key = (string) $_value;
|
||||
break;
|
||||
|
||||
case 'tr_attr':
|
||||
|
@ -129,7 +130,7 @@ function smarty_function_html_table($params, $template)
|
|||
$cols = ($hdir == 'right') ? $cols : array_reverse($cols);
|
||||
$output .= "<thead><tr>\n";
|
||||
|
||||
for ($r = 0; $r < $cols_count; $r++) {
|
||||
for ($r = 0; $r < $cols_count; $r ++) {
|
||||
$output .= '<th' . smarty_function_html_table_cycle('th', $th_attr, $r) . '>';
|
||||
$output .= $cols[$r];
|
||||
$output .= "</th>\n";
|
||||
|
@ -138,12 +139,12 @@ function smarty_function_html_table($params, $template)
|
|||
}
|
||||
|
||||
$output .= "<tbody>\n";
|
||||
for ($r = 0; $r < $rows; $r++) {
|
||||
for ($r = 0; $r < $rows; $r ++) {
|
||||
$output .= "<tr" . smarty_function_html_table_cycle('tr', $tr_attr, $r) . ">\n";
|
||||
$rx = ($vdir == 'down') ? $r * $cols_count : ($rows-1 - $r) * $cols_count;
|
||||
$rx = ($vdir == 'down') ? $r * $cols_count : ($rows - 1 - $r) * $cols_count;
|
||||
|
||||
for ($c = 0; $c < $cols_count; $c++) {
|
||||
$x = ($hdir == 'right') ? $rx + $c : $rx + $cols_count-1 - $c;
|
||||
for ($c = 0; $c < $cols_count; $c ++) {
|
||||
$x = ($hdir == 'right') ? $rx + $c : $rx + $cols_count - 1 - $c;
|
||||
if ($inner != 'cols') {
|
||||
/* shuffle x to loop over rows*/
|
||||
$x = floor($x / $cols_count) + ($x % $cols_count) * $rows;
|
||||
|
@ -173,5 +174,3 @@ function smarty_function_html_table_cycle($name, $var, $no)
|
|||
|
||||
return ($ret) ? ' ' . $ret : '';
|
||||
}
|
||||
|
||||
?>
|
|
@ -2,13 +2,12 @@
|
|||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {mailto} function plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: mailto<br>
|
||||
* Date: May 21, 2002
|
||||
|
@ -39,22 +38,24 @@
|
|||
* {mailto address="me@domain.com" extra='class="mailto"'}
|
||||
* </pre>
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.mailto.php {mailto}
|
||||
* (Smarty online manual)
|
||||
* @version 1.2
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author credits to Jason Sweat (added cc, bcc and subject functionality)
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
* @link http://www.smarty.net/manual/en/language.function.mailto.php {mailto}
|
||||
* (Smarty online manual)
|
||||
* @version 1.2
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author credits to Jason Sweat (added cc, bcc and subject functionality)
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_function_mailto($params, $template)
|
||||
function smarty_function_mailto($params)
|
||||
{
|
||||
static $_allowed_encoding = array('javascript' => true, 'javascript_charcode' => true, 'hex' => true, 'none' => true);
|
||||
$extra = '';
|
||||
|
||||
if (empty($params['address'])) {
|
||||
trigger_error("mailto: missing 'address' parameter",E_USER_WARNING);
|
||||
trigger_error("mailto: missing 'address' parameter", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
} else {
|
||||
$address = $params['address'];
|
||||
|
@ -71,8 +72,9 @@ function smarty_function_mailto($params, $template)
|
|||
case 'cc':
|
||||
case 'bcc':
|
||||
case 'followupto':
|
||||
if (!empty($value))
|
||||
$mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value));
|
||||
if (!empty($value)) {
|
||||
$mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'subject':
|
||||
|
@ -91,10 +93,11 @@ function smarty_function_mailto($params, $template)
|
|||
if ($mail_parms) {
|
||||
$address .= '?' . join('&', $mail_parms);
|
||||
}
|
||||
|
||||
|
||||
$encode = (empty($params['encode'])) ? 'none' : $params['encode'];
|
||||
if (!isset($_allowed_encoding[$encode])) {
|
||||
trigger_error("mailto: 'encode' parameter must be none, javascript, javascript_charcode or hex", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
}
|
||||
// FIXME: (rodneyrehm) document.write() excues me what? 1998 has passed!
|
||||
|
@ -102,7 +105,7 @@ function smarty_function_mailto($params, $template)
|
|||
$string = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');';
|
||||
|
||||
$js_encode = '';
|
||||
for ($x = 0, $_length = strlen($string); $x < $_length; $x++) {
|
||||
for ($x = 0, $_length = strlen($string); $x < $_length; $x ++) {
|
||||
$js_encode .= '%' . bin2hex($string[$x]);
|
||||
}
|
||||
|
||||
|
@ -110,7 +113,7 @@ function smarty_function_mailto($params, $template)
|
|||
} elseif ($encode == 'javascript_charcode') {
|
||||
$string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
|
||||
|
||||
for($x = 0, $y = strlen($string); $x < $y; $x++) {
|
||||
for ($x = 0, $y = strlen($string); $x < $y; $x ++) {
|
||||
$ord[] = ord($string[$x]);
|
||||
}
|
||||
|
||||
|
@ -125,11 +128,12 @@ function smarty_function_mailto($params, $template)
|
|||
} elseif ($encode == 'hex') {
|
||||
preg_match('!^(.*)(\?.*)$!', $address, $match);
|
||||
if (!empty($match[2])) {
|
||||
trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.",E_USER_WARNING);
|
||||
trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
}
|
||||
$address_encode = '';
|
||||
for ($x = 0, $_length = strlen($address); $x < $_length; $x++) {
|
||||
for ($x = 0, $_length = strlen($address); $x < $_length; $x ++) {
|
||||
if (preg_match('!\w!' . Smarty::$_UTF8_MODIFIER, $address[$x])) {
|
||||
$address_encode .= '%' . bin2hex($address[$x]);
|
||||
} else {
|
||||
|
@ -137,16 +141,15 @@ function smarty_function_mailto($params, $template)
|
|||
}
|
||||
}
|
||||
$text_encode = '';
|
||||
for ($x = 0, $_length = strlen($text); $x < $_length; $x++) {
|
||||
for ($x = 0, $_length = strlen($text); $x < $_length; $x ++) {
|
||||
$text_encode .= '&#x' . bin2hex($text[$x]) . ';';
|
||||
}
|
||||
|
||||
$mailto = "mailto:";
|
||||
|
||||
return '<a href="' . $mailto . $address_encode . '" ' . $extra . '>' . $text_encode . '</a>';
|
||||
} else {
|
||||
// no encoding
|
||||
return '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,87 +1,91 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* This plugin is only for Smarty2 BC
|
||||
* @package Smarty
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {math} function plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: math<br>
|
||||
* Purpose: handle math computations in template
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.math.php {math}
|
||||
* (Smarty online manual)
|
||||
* @link http://www.smarty.net/manual/en/language.function.math.php {math}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
function smarty_function_math($params, $template)
|
||||
{
|
||||
static $_allowed_funcs = array(
|
||||
'int' => true, 'abs' => true, 'ceil' => true, 'cos' => true, 'exp' => true, 'floor' => true,
|
||||
'log' => true, 'log10' => true, 'max' => true, 'min' => true, 'pi' => true, 'pow' => true,
|
||||
'rand' => true, 'round' => true, 'sin' => true, 'sqrt' => true, 'srand' => true ,'tan' => true
|
||||
'int' => true, 'abs' => true, 'ceil' => true, 'cos' => true, 'exp' => true, 'floor' => true,
|
||||
'log' => true, 'log10' => true, 'max' => true, 'min' => true, 'pi' => true, 'pow' => true,
|
||||
'rand' => true, 'round' => true, 'sin' => true, 'sqrt' => true, 'srand' => true, 'tan' => true
|
||||
);
|
||||
// be sure equation parameter is present
|
||||
if (empty($params['equation'])) {
|
||||
trigger_error("math: missing equation parameter",E_USER_WARNING);
|
||||
trigger_error("math: missing equation parameter", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$equation = $params['equation'];
|
||||
|
||||
// make sure parenthesis are balanced
|
||||
if (substr_count($equation,"(") != substr_count($equation,")")) {
|
||||
trigger_error("math: unbalanced parenthesis",E_USER_WARNING);
|
||||
if (substr_count($equation, "(") != substr_count($equation, ")")) {
|
||||
trigger_error("math: unbalanced parenthesis", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// match all vars in equation, make sure all are passed
|
||||
preg_match_all("!(?:0x[a-fA-F0-9]+)|([a-zA-Z][a-zA-Z0-9_]*)!",$equation, $match);
|
||||
preg_match_all("!(?:0x[a-fA-F0-9]+)|([a-zA-Z][a-zA-Z0-9_]*)!", $equation, $match);
|
||||
|
||||
foreach($match[1] as $curr_var) {
|
||||
foreach ($match[1] as $curr_var) {
|
||||
if ($curr_var && !isset($params[$curr_var]) && !isset($_allowed_funcs[$curr_var])) {
|
||||
trigger_error("math: function call $curr_var not allowed",E_USER_WARNING);
|
||||
trigger_error("math: function call $curr_var not allowed", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($params as $key => $val) {
|
||||
foreach ($params as $key => $val) {
|
||||
if ($key != "equation" && $key != "format" && $key != "assign") {
|
||||
// make sure value is not empty
|
||||
if (strlen($val)==0) {
|
||||
trigger_error("math: parameter $key is empty",E_USER_WARNING);
|
||||
if (strlen($val) == 0) {
|
||||
trigger_error("math: parameter $key is empty", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
}
|
||||
if (!is_numeric($val)) {
|
||||
trigger_error("math: parameter $key: is not numeric",E_USER_WARNING);
|
||||
trigger_error("math: parameter $key: is not numeric", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
}
|
||||
$equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation);
|
||||
}
|
||||
}
|
||||
$smarty_math_result = null;
|
||||
eval("\$smarty_math_result = ".$equation.";");
|
||||
eval("\$smarty_math_result = " . $equation . ";");
|
||||
|
||||
if (empty($params['format'])) {
|
||||
if (empty($params['assign'])) {
|
||||
return $smarty_math_result;
|
||||
} else {
|
||||
$template->assign($params['assign'],$smarty_math_result);
|
||||
$template->assign($params['assign'], $smarty_math_result);
|
||||
}
|
||||
} else {
|
||||
if (empty($params['assign'])){
|
||||
printf($params['format'],$smarty_math_result);
|
||||
if (empty($params['assign'])) {
|
||||
printf($params['format'], $smarty_math_result);
|
||||
} else {
|
||||
$template->assign($params['assign'],sprintf($params['format'],$smarty_math_result));
|
||||
$template->assign($params['assign'], sprintf($params['format'], $smarty_math_result));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,25 +1,24 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty capitalize modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: capitalize<br>
|
||||
* Purpose: capitalize words in the string
|
||||
*
|
||||
* {@internal {$string|capitalize:true:true} is the fastest option for MBString enabled systems }}
|
||||
*
|
||||
* @param string $string string to capitalize
|
||||
* @param boolean $uc_digits also capitalize "x123" to "X123"
|
||||
* @param boolean $lc_rest capitalize first letters, lowercase all following letters "aAa" to "Aaa"
|
||||
*
|
||||
* @return string capitalized string
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = false)
|
||||
|
@ -27,39 +26,65 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
|
|||
if (Smarty::$_MBSTRING) {
|
||||
if ($lc_rest) {
|
||||
// uppercase (including hyphenated words)
|
||||
$upper_string = mb_convert_case( $string, MB_CASE_TITLE, Smarty::$_CHARSET );
|
||||
$upper_string = mb_convert_case($string, MB_CASE_TITLE, Smarty::$_CHARSET);
|
||||
} else {
|
||||
// uppercase word breaks
|
||||
$upper_string = preg_replace("!(^|[^\p{L}'])([\p{Ll}])!eS" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').mb_convert_case(stripslashes('\\2'),MB_CASE_UPPER, '" . addslashes(Smarty::$_CHARSET) . "')", $string);
|
||||
$upper_string = preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_mbconvert_cb', $string);
|
||||
}
|
||||
// check uc_digits case
|
||||
if (!$uc_digits) {
|
||||
if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, PREG_OFFSET_CAPTURE)) {
|
||||
foreach($matches[1] as $match) {
|
||||
foreach ($matches[1] as $match) {
|
||||
$upper_string = substr_replace($upper_string, mb_strtolower($match[0], Smarty::$_CHARSET), $match[1], strlen($match[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$upper_string = preg_replace("!((^|\s)['\"])(\w)!e" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').mb_convert_case(stripslashes('\\3'),MB_CASE_UPPER, '" . addslashes(Smarty::$_CHARSET) . "')", $upper_string);
|
||||
$upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_mbconvert2_cb', $upper_string);
|
||||
return $upper_string;
|
||||
}
|
||||
|
||||
|
||||
// lowercase first
|
||||
if ($lc_rest) {
|
||||
$string = strtolower($string);
|
||||
}
|
||||
// uppercase (including hyphenated words)
|
||||
$upper_string = preg_replace("!(^|[^\p{L}'])([\p{Ll}])!eS" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').ucfirst(stripslashes('\\2'))", $string);
|
||||
$upper_string = preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst_cb', $string);
|
||||
// check uc_digits case
|
||||
if (!$uc_digits) {
|
||||
if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, PREG_OFFSET_CAPTURE)) {
|
||||
foreach($matches[1] as $match) {
|
||||
foreach ($matches[1] as $match) {
|
||||
$upper_string = substr_replace($upper_string, strtolower($match[0]), $match[1], strlen($match[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$upper_string = preg_replace("!((^|\s)['\"])(\w)!e" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').strtoupper(stripslashes('\\3'))", $upper_string);
|
||||
$upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst2_cb', $upper_string);
|
||||
return $upper_string;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
/*
|
||||
*
|
||||
* Bug: create_function() use exhausts memory when used in long loops
|
||||
* Fix: use declared functions for callbacks instead of using create_function()
|
||||
* Note: This can be fixed using anonymous functions instead, but that requires PHP >= 5.3
|
||||
*
|
||||
* @author Kyle Renfrow
|
||||
*/
|
||||
function smarty_mod_cap_mbconvert_cb($matches)
|
||||
{
|
||||
return stripslashes($matches[1]) . mb_convert_case(stripslashes($matches[2]), MB_CASE_UPPER, Smarty::$_CHARSET);
|
||||
}
|
||||
|
||||
function smarty_mod_cap_mbconvert2_cb($matches)
|
||||
{
|
||||
return stripslashes($matches[1]) . mb_convert_case(stripslashes($matches[3]), MB_CASE_UPPER, Smarty::$_CHARSET);
|
||||
}
|
||||
|
||||
function smarty_mod_cap_ucfirst_cb($matches)
|
||||
{
|
||||
return stripslashes($matches[1]) . ucfirst(stripslashes($matches[2]));
|
||||
}
|
||||
|
||||
function smarty_mod_cap_ucfirst2_cb($matches)
|
||||
{
|
||||
return stripslashes($matches[1]) . ucfirst(stripslashes($matches[3]));
|
||||
}
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty date_format modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: date_format<br>
|
||||
* Purpose: format datestamps via strftime<br>
|
||||
|
@ -16,24 +15,26 @@
|
|||
* - string: input date string
|
||||
* - format: strftime format for output
|
||||
* - default_date: default date if $string is empty
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param string $string input date string
|
||||
* @param string $format strftime format for output
|
||||
* @param string $default_date default date if $string is empty
|
||||
* @param string $formatter either 'strftime' or 'auto'
|
||||
*
|
||||
* @return string |void
|
||||
* @uses smarty_make_timestamp()
|
||||
* @uses smarty_make_timestamp()
|
||||
*/
|
||||
function smarty_modifier_date_format($string, $format=null, $default_date='', $formatter='auto')
|
||||
function smarty_modifier_date_format($string, $format = null, $default_date = '', $formatter = 'auto')
|
||||
{
|
||||
if ($format === null) {
|
||||
$format = Smarty::$_DATE_FORMAT;
|
||||
}
|
||||
/**
|
||||
* Include the {@link shared.make_timestamp.php} plugin
|
||||
*/
|
||||
* Include the {@link shared.make_timestamp.php} plugin
|
||||
*/
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
if ($string != '' && $string != '0000-00-00' && $string != '0000-00-00 00:00:00') {
|
||||
$timestamp = smarty_make_timestamp($string);
|
||||
|
@ -41,25 +42,24 @@ function smarty_modifier_date_format($string, $format=null, $default_date='', $f
|
|||
$timestamp = smarty_make_timestamp($default_date);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if($formatter=='strftime'||($formatter=='auto'&&strpos($format,'%')!==false)) {
|
||||
}
|
||||
if ($formatter == 'strftime' || ($formatter == 'auto' && strpos($format, '%') !== false)) {
|
||||
if (DS == '\\') {
|
||||
$_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T');
|
||||
$_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S');
|
||||
if (strpos($format, '%e') !== false) {
|
||||
$_win_from[] = '%e';
|
||||
$_win_to[] = sprintf('%\' 2d', date('j', $timestamp));
|
||||
}
|
||||
}
|
||||
if (strpos($format, '%l') !== false) {
|
||||
$_win_from[] = '%l';
|
||||
$_win_to[] = sprintf('%\' 2d', date('h', $timestamp));
|
||||
}
|
||||
}
|
||||
$format = str_replace($_win_from, $_win_to, $format);
|
||||
}
|
||||
}
|
||||
|
||||
return strftime($format, $timestamp);
|
||||
} else {
|
||||
return date($format, $timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
||||
|
|
|
@ -1,53 +1,54 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Debug
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty debug_print_var modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: debug_print_var<br>
|
||||
* Purpose: formats variable contents for display in the console
|
||||
*
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param array|object $var variable to be formatted
|
||||
* @param integer $depth maximum recursion depth if $var is an array
|
||||
* @param integer $length maximum string length if $var is a string
|
||||
* @return string
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param array|object $var variable to be formatted
|
||||
* @param integer $depth maximum recursion depth if $var is an array
|
||||
* @param integer $length maximum string length if $var is a string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_debug_print_var ($var, $depth = 0, $length = 40)
|
||||
function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
|
||||
{
|
||||
$_replace = array("\n" => '<i>\n</i>',
|
||||
"\r" => '<i>\r</i>',
|
||||
"\t" => '<i>\t</i>'
|
||||
);
|
||||
"\r" => '<i>\r</i>',
|
||||
"\t" => '<i>\t</i>'
|
||||
);
|
||||
|
||||
switch (gettype($var)) {
|
||||
case 'array' :
|
||||
$results = '<b>Array (' . count($var) . ')</b>';
|
||||
foreach ($var as $curr_key => $curr_val) {
|
||||
$results .= '<br>' . str_repeat(' ', $depth * 2)
|
||||
. '<b>' . strtr($curr_key, $_replace) . '</b> => '
|
||||
. smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
|
||||
$depth--;
|
||||
}
|
||||
. '<b>' . strtr($curr_key, $_replace) . '</b> => '
|
||||
. smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
|
||||
$depth --;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'object' :
|
||||
$object_vars = get_object_vars($var);
|
||||
$results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
|
||||
foreach ($object_vars as $curr_key => $curr_val) {
|
||||
$results .= '<br>' . str_repeat(' ', $depth * 2)
|
||||
. '<b> ->' . strtr($curr_key, $_replace) . '</b> = '
|
||||
. smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
|
||||
$depth--;
|
||||
}
|
||||
. '<b> ->' . strtr($curr_key, $_replace) . '</b> = '
|
||||
. smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
|
||||
$depth --;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'boolean' :
|
||||
case 'NULL' :
|
||||
case 'resource' :
|
||||
|
@ -59,15 +60,15 @@ function smarty_modifier_debug_print_var ($var, $depth = 0, $length = 40)
|
|||
$results = 'null';
|
||||
} else {
|
||||
$results = htmlspecialchars((string) $var);
|
||||
}
|
||||
}
|
||||
$results = '<i>' . $results . '</i>';
|
||||
break;
|
||||
|
||||
|
||||
case 'integer' :
|
||||
case 'float' :
|
||||
$results = htmlspecialchars((string) $var);
|
||||
break;
|
||||
|
||||
|
||||
case 'string' :
|
||||
$results = strtr($var, $_replace);
|
||||
if (Smarty::$_MBSTRING) {
|
||||
|
@ -82,7 +83,7 @@ function smarty_modifier_debug_print_var ($var, $depth = 0, $length = 40)
|
|||
|
||||
$results = htmlspecialchars('"' . $results . '"');
|
||||
break;
|
||||
|
||||
|
||||
case 'unknown type' :
|
||||
default :
|
||||
$results = strtr((string) $var, $_replace);
|
||||
|
@ -95,11 +96,9 @@ function smarty_modifier_debug_print_var ($var, $depth = 0, $length = 40)
|
|||
$results = substr($results, 0, $length - 3) . '...';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$results = htmlspecialchars($results);
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
||||
|
|
|
@ -2,23 +2,24 @@
|
|||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty escape modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: escape<br>
|
||||
* Purpose: escape string for output
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual)
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param string $string input string
|
||||
* @param string $esc_type escape type
|
||||
* @param string $char_set character set, used for htmlspecialchars() or htmlentities()
|
||||
* @param boolean $double_encode encode already encoded entitites again, used for htmlspecialchars() or htmlentities()
|
||||
*
|
||||
* @return string escaped input string
|
||||
*/
|
||||
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true)
|
||||
|
@ -27,7 +28,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
|||
if ($_double_encode === null) {
|
||||
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
|
||||
}
|
||||
|
||||
|
||||
if (!$char_set) {
|
||||
$char_set = Smarty::$_CHARSET;
|
||||
}
|
||||
|
@ -39,13 +40,14 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
|||
return htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
|
||||
} else {
|
||||
if ($double_encode) {
|
||||
// php <5.3.2 - only handle double encoding
|
||||
// php <5.2.3 - only handle double encoding
|
||||
return htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||
} else {
|
||||
// php <5.3.2 - prevent double encoding
|
||||
// php <5.2.3 - prevent double encoding
|
||||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||
$string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
|
||||
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
@ -58,17 +60,18 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
|||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
|
||||
} else {
|
||||
if ($double_encode) {
|
||||
// php <5.3.2 - only handle double encoding
|
||||
// php <5.2.3 - only handle double encoding
|
||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||
} else {
|
||||
// php <5.3.2 - prevent double encoding
|
||||
// php <5.2.3 - prevent double encoding
|
||||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||
$string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
|
||||
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// htmlentities() won't convert everything, so use mb_convert_encoding
|
||||
return mb_convert_encoding($string, 'HTML-ENTITIES', $char_set);
|
||||
}
|
||||
|
@ -83,6 +86,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
|||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||
$string = htmlentities($string, ENT_QUOTES, $char_set);
|
||||
$string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
|
||||
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
@ -102,9 +106,10 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
|||
// Note that the UTF-8 encoded character ä will be represented as %c3%a4
|
||||
$return = '';
|
||||
$_length = strlen($string);
|
||||
for ($x = 0; $x < $_length; $x++) {
|
||||
for ($x = 0; $x < $_length; $x ++) {
|
||||
$return .= '%' . bin2hex($string[$x]);
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
||||
case 'hexentity':
|
||||
|
@ -115,13 +120,15 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
|||
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
||||
$return .= '&#x' . strtoupper(dechex($unicode)) . ';';
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
// no MBString fallback
|
||||
$_length = strlen($string);
|
||||
for ($x = 0; $x < $_length; $x++) {
|
||||
for ($x = 0; $x < $_length; $x ++) {
|
||||
$return .= '&#x' . bin2hex($string[$x]) . ';';
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
||||
case 'decentity':
|
||||
|
@ -132,13 +139,15 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
|||
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
||||
$return .= '&#' . $unicode . ';';
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
// no MBString fallback
|
||||
$_length = strlen($string);
|
||||
for ($x = 0; $x < $_length; $x++) {
|
||||
for ($x = 0; $x < $_length; $x ++) {
|
||||
$return .= '&#' . ord($string[$x]) . ';';
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
||||
case 'javascript':
|
||||
|
@ -148,6 +157,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
|||
case 'mail':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
|
||||
|
||||
return smarty_mb_str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string);
|
||||
}
|
||||
// no MBString fallback
|
||||
|
@ -165,11 +175,12 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
|||
$return .= chr($unicode);
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
$_length = strlen($string);
|
||||
for ($_i = 0; $_i < $_length; $_i++) {
|
||||
for ($_i = 0; $_i < $_length; $_i ++) {
|
||||
$_ord = ord(substr($string, $_i, 1));
|
||||
// non-standard char, escape it
|
||||
if ($_ord >= 126) {
|
||||
|
@ -178,11 +189,10 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
|||
$return .= substr($string, $_i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
||||
default:
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -2,39 +2,42 @@
|
|||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty regex_replace modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: regex_replace<br>
|
||||
* Purpose: regular expression search/replace
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php
|
||||
* regex_replace (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param string $string input string
|
||||
* @param string|array $search regular expression(s) to search for
|
||||
* @param string|array $replace string(s) that should be replaced
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param string $string input string
|
||||
* @param string|array $search regular expression(s) to search for
|
||||
* @param string|array $replace string(s) that should be replaced
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_regex_replace($string, $search, $replace)
|
||||
{
|
||||
if(is_array($search)) {
|
||||
foreach($search as $idx => $s) {
|
||||
if (is_array($search)) {
|
||||
foreach ($search as $idx => $s) {
|
||||
$search[$idx] = _smarty_regex_replace_check($s);
|
||||
}
|
||||
} else {
|
||||
$search = _smarty_regex_replace_check($search);
|
||||
}
|
||||
|
||||
return preg_replace($search, $replace, $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $search string(s) that should be replaced
|
||||
*
|
||||
* @return string
|
||||
* @ignore
|
||||
*/
|
||||
|
@ -42,14 +45,13 @@ function _smarty_regex_replace_check($search)
|
|||
{
|
||||
// null-byte injection detection
|
||||
// anything behind the first null-byte is ignored
|
||||
if (($pos = strpos($search,"\0")) !== false) {
|
||||
$search = substr($search,0,$pos);
|
||||
if (($pos = strpos($search, "\0")) !== false) {
|
||||
$search = substr($search, 0, $pos);
|
||||
}
|
||||
// remove eval-modifier from $search
|
||||
if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) {
|
||||
$search = substr($search, 0, -strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]);
|
||||
$search = substr($search, 0, - strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]);
|
||||
}
|
||||
|
||||
return $search;
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,33 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty replace modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: replace<br>
|
||||
* Purpose: simple search/replace
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param string $string input string
|
||||
* @param string $search text to search for
|
||||
* @param string $replace replacement text
|
||||
* @return string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_replace($string, $search, $replace)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
|
||||
|
||||
return smarty_mb_str_replace($search, $replace, $string);
|
||||
}
|
||||
|
||||
return str_replace($search, $replace, $string);
|
||||
}
|
||||
|
||||
?>
|
||||
return str_replace($search, $replace, $string);
|
||||
}
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty spacify modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: spacify<br>
|
||||
* Purpose: add spaces between characters in a string
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param string $string input string
|
||||
* @param string $spacify_char string to insert between characters.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_spacify($string, $spacify_char = ' ')
|
||||
{
|
||||
// well… what about charsets besides latin and UTF-8?
|
||||
return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, -1, PREG_SPLIT_NO_EMPTY));
|
||||
}
|
||||
|
||||
?>
|
||||
return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, - 1, PREG_SPLIT_NO_EMPTY));
|
||||
}
|
||||
|
|
|
@ -2,58 +2,63 @@
|
|||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Smarty truncate modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: truncate<br>
|
||||
* Purpose: Truncate a string to a certain length if necessary,
|
||||
* optionally splitting in the middle of a word, and
|
||||
* appending the $etc string or inserting $etc into the middle.
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.truncate.php truncate (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.truncate.php truncate (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param string $string input string
|
||||
* @param integer $length length of truncated text
|
||||
* @param string $etc end string
|
||||
* @param boolean $break_words truncate at word boundary
|
||||
* @param boolean $middle truncate in the middle of text
|
||||
*
|
||||
* @return string truncated string
|
||||
*/
|
||||
function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false) {
|
||||
if ($length == 0)
|
||||
function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false)
|
||||
{
|
||||
if ($length == 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (mb_strlen($string, Smarty::$_CHARSET) > $length) {
|
||||
$length -= min($length, mb_strlen($etc, Smarty::$_CHARSET));
|
||||
if (!$break_words && !$middle) {
|
||||
$string = preg_replace('/\s+?(\S+)?$/' . Smarty::$_UTF8_MODIFIER, '', mb_substr($string, 0, $length + 1, Smarty::$_CHARSET));
|
||||
}
|
||||
}
|
||||
if (!$middle) {
|
||||
return mb_substr($string, 0, $length, Smarty::$_CHARSET) . $etc;
|
||||
}
|
||||
|
||||
return mb_substr($string, 0, $length / 2, Smarty::$_CHARSET) . $etc . mb_substr($string, - $length / 2, $length, Smarty::$_CHARSET);
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
|
||||
// no MBString fallback
|
||||
if (isset($string[$length])) {
|
||||
$length -= min($length, strlen($etc));
|
||||
if (!$break_words && !$middle) {
|
||||
$string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1));
|
||||
}
|
||||
}
|
||||
if (!$middle) {
|
||||
return substr($string, 0, $length) . $etc;
|
||||
}
|
||||
|
||||
return substr($string, 0, $length / 2) . $etc . substr($string, - $length / 2);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
?>
|
||||
return $string;
|
||||
}
|
||||
|
|
|
@ -1,30 +1,29 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty cat modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: cat<br>
|
||||
* Date: Feb 24, 2003<br>
|
||||
* Purpose: catenate a value to a variable<br>
|
||||
* Input: string to catenate<br>
|
||||
* Example: {$var|cat:"foo"}
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.cat.php cat
|
||||
* (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_cat($params, $compiler)
|
||||
{
|
||||
return '('.implode(').(', $params).')';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty cat modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: cat<br>
|
||||
* Date: Feb 24, 2003<br>
|
||||
* Purpose: catenate a value to a variable<br>
|
||||
* Input: string to catenate<br>
|
||||
* Example: {$var|cat:"foo"}
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.cat.php cat
|
||||
* (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_cat($params)
|
||||
{
|
||||
return '(' . implode(').(', $params) . ')';
|
||||
}
|
||||
|
|
|
@ -1,33 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty count_characters modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: count_characteres<br>
|
||||
* Purpose: count the number of characters in a text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_count_characters($params, $compiler)
|
||||
{
|
||||
if (!isset($params[1]) || $params[1] != 'true') {
|
||||
return 'preg_match_all(\'/[^\s]/' . Smarty::$_UTF8_MODIFIER . '\',' . $params[0] . ', $tmp)';
|
||||
}
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strlen(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strlen(' . $params[0] . ')';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty count_characters modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: count_characteres<br>
|
||||
* Purpose: count the number of characters in a text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_count_characters($params)
|
||||
{
|
||||
if (!isset($params[1]) || $params[1] != 'true') {
|
||||
return 'preg_match_all(\'/[^\s]/' . Smarty::$_UTF8_MODIFIER . '\',' . $params[0] . ', $tmp)';
|
||||
}
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strlen(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strlen(' . $params[0] . ')';
|
||||
}
|
||||
|
|
|
@ -1,28 +1,27 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty count_paragraphs modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: count_paragraphs<br>
|
||||
* Purpose: count the number of paragraphs in a text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
||||
* count_paragraphs (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_count_paragraphs($params, $compiler)
|
||||
{
|
||||
// count \r or \n characters
|
||||
return '(preg_match_all(\'#[\r\n]+#\', ' . $params[0] . ', $tmp)+1)';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty count_paragraphs modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: count_paragraphs<br>
|
||||
* Purpose: count the number of paragraphs in a text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
||||
* count_paragraphs (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_count_paragraphs($params)
|
||||
{
|
||||
// count \r or \n characters
|
||||
return '(preg_match_all(\'#[\r\n]+#\', ' . $params[0] . ', $tmp)+1)';
|
||||
}
|
||||
|
|
|
@ -1,28 +1,27 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty count_sentences modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: count_sentences
|
||||
* Purpose: count the number of sentences in a text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
||||
* count_sentences (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_count_sentences($params, $compiler)
|
||||
{
|
||||
// find periods, question marks, exclamation marks with a word before but not after.
|
||||
return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[0] . ', $tmp)';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty count_sentences modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: count_sentences
|
||||
* Purpose: count the number of sentences in a text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
||||
* count_sentences (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_count_sentences($params)
|
||||
{
|
||||
// find periods, question marks, exclamation marks with a word before but not after.
|
||||
return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[0] . ', $tmp)';
|
||||
}
|
||||
|
|
|
@ -1,32 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty count_words modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: count_words<br>
|
||||
* Purpose: count the number of words in a text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_count_words($params, $compiler)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
// return 'preg_match_all(\'#[\w\pL]+#' . Smarty::$_UTF8_MODIFIER . '\', ' . $params[0] . ', $tmp)';
|
||||
// expression taken from http://de.php.net/manual/en/function.str-word-count.php#85592
|
||||
return 'preg_match_all(\'/\p{L}[\p{L}\p{Mn}\p{Pd}\\\'\x{2019}]*/' . Smarty::$_UTF8_MODIFIER . '\', ' . $params[0] . ', $tmp)';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'str_word_count(' . $params[0] . ')';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty count_words modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: count_words<br>
|
||||
* Purpose: count the number of words in a text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_count_words($params)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
// return 'preg_match_all(\'#[\w\pL]+#' . Smarty::$_UTF8_MODIFIER . '\', ' . $params[0] . ', $tmp)';
|
||||
// expression taken from http://de.php.net/manual/en/function.str-word-count.php#85592
|
||||
return 'preg_match_all(\'/\p{L}[\p{L}\p{Mn}\p{Pd}\\\'\x{2019}]*/' . Smarty::$_UTF8_MODIFIER . '\', ' . $params[0] . ', $tmp)';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'str_word_count(' . $params[0] . ')';
|
||||
}
|
||||
|
|
|
@ -1,35 +1,35 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty default modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: default<br>
|
||||
* Purpose: designate default value for empty variables
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_default ($params, $compiler)
|
||||
{
|
||||
$output = $params[0];
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = "''";
|
||||
}
|
||||
|
||||
array_shift($params);
|
||||
foreach ($params as $param) {
|
||||
$output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $param . ' : $tmp)';
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty default modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: default<br>
|
||||
* Purpose: designate default value for empty variables
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_default($params)
|
||||
{
|
||||
$output = $params[0];
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = "''";
|
||||
}
|
||||
|
||||
array_shift($params);
|
||||
foreach ($params as $param) {
|
||||
$output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $param . ' : $tmp)';
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
|
|
@ -1,125 +1,126 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require_once( SMARTY_PLUGINS_DIR .'shared.literal_compiler_param.php' );
|
||||
|
||||
/**
|
||||
* Smarty escape modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: escape<br>
|
||||
* Purpose: escape string for output
|
||||
*
|
||||
* @link http://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual)
|
||||
* @author Rodney Rehm
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_escape($params, $compiler)
|
||||
{
|
||||
static $_double_encode = null;
|
||||
if ($_double_encode === null) {
|
||||
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
|
||||
}
|
||||
|
||||
try {
|
||||
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
|
||||
$char_set = smarty_literal_compiler_param($params, 2, Smarty::$_CHARSET);
|
||||
$double_encode = smarty_literal_compiler_param($params, 3, true);
|
||||
|
||||
if (!$char_set) {
|
||||
$char_set = Smarty::$_CHARSET;
|
||||
}
|
||||
|
||||
switch ($esc_type) {
|
||||
case 'html':
|
||||
if ($_double_encode) {
|
||||
return 'htmlspecialchars('
|
||||
. $params[0] .', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ', '
|
||||
. var_export($double_encode, true) . ')';
|
||||
} else if ($double_encode) {
|
||||
return 'htmlspecialchars('
|
||||
. $params[0] .', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ')';
|
||||
} else {
|
||||
// fall back to modifier.escape.php
|
||||
}
|
||||
|
||||
case 'htmlall':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if ($_double_encode) {
|
||||
// php >=5.3.2 - go native
|
||||
return 'mb_convert_encoding(htmlspecialchars('
|
||||
. $params[0] .', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ', '
|
||||
. var_export($double_encode, true)
|
||||
. '), "HTML-ENTITIES", '
|
||||
. var_export($char_set, true) . ')';
|
||||
} else if ($double_encode) {
|
||||
// php <5.3.2 - only handle double encoding
|
||||
return 'mb_convert_encoding(htmlspecialchars('
|
||||
. $params[0] .', ENT_QUOTES, '
|
||||
. var_export($char_set, true)
|
||||
. '), "HTML-ENTITIES", '
|
||||
. var_export($char_set, true) . ')';
|
||||
} else {
|
||||
// fall back to modifier.escape.php
|
||||
}
|
||||
}
|
||||
|
||||
// no MBString fallback
|
||||
if ($_double_encode) {
|
||||
// php >=5.3.2 - go native
|
||||
return 'htmlentities('
|
||||
. $params[0] .', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ', '
|
||||
. var_export($double_encode, true) . ')';
|
||||
} else if ($double_encode) {
|
||||
// php <5.3.2 - only handle double encoding
|
||||
return 'htmlentities('
|
||||
. $params[0] .', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ')';
|
||||
} else {
|
||||
// fall back to modifier.escape.php
|
||||
}
|
||||
|
||||
case 'url':
|
||||
return 'rawurlencode(' . $params[0] . ')';
|
||||
|
||||
case 'urlpathinfo':
|
||||
return 'str_replace("%2F", "/", rawurlencode(' . $params[0] . '))';
|
||||
|
||||
case 'quotes':
|
||||
// escape unescaped single quotes
|
||||
return 'preg_replace("%(?<!\\\\\\\\)\'%", "\\\'",' . $params[0] . ')';
|
||||
|
||||
case 'javascript':
|
||||
// escape quotes and backslashes, newlines, etc.
|
||||
return 'strtr(' . $params[0] . ', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/" ))';
|
||||
|
||||
}
|
||||
} catch(SmartyException $e) {
|
||||
// pass through to regular plugin fallback
|
||||
}
|
||||
|
||||
// could not optimize |escape call, so fallback to regular plugin
|
||||
if ($compiler->tag_nocache | $compiler->nocache) {
|
||||
$compiler->template->required_plugins['nocache']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR .'modifier.escape.php';
|
||||
$compiler->template->required_plugins['nocache']['escape']['modifier']['function'] = 'smarty_modifier_escape';
|
||||
} else {
|
||||
$compiler->template->required_plugins['compiled']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR .'modifier.escape.php';
|
||||
$compiler->template->required_plugins['compiled']['escape']['modifier']['function'] = 'smarty_modifier_escape';
|
||||
}
|
||||
return 'smarty_modifier_escape(' . join( ', ', $params ) . ')';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php');
|
||||
|
||||
/**
|
||||
* Smarty escape modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: escape<br>
|
||||
* Purpose: escape string for output
|
||||
*
|
||||
* @link http://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual)
|
||||
* @author Rodney Rehm
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param $compiler
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_escape($params, $compiler)
|
||||
{
|
||||
static $_double_encode = null;
|
||||
if ($_double_encode === null) {
|
||||
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
|
||||
}
|
||||
|
||||
try {
|
||||
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
|
||||
$char_set = smarty_literal_compiler_param($params, 2, Smarty::$_CHARSET);
|
||||
$double_encode = smarty_literal_compiler_param($params, 3, true);
|
||||
|
||||
if (!$char_set) {
|
||||
$char_set = Smarty::$_CHARSET;
|
||||
}
|
||||
|
||||
switch ($esc_type) {
|
||||
case 'html':
|
||||
if ($_double_encode) {
|
||||
return 'htmlspecialchars('
|
||||
. $params[0] . ', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ', '
|
||||
. var_export($double_encode, true) . ')';
|
||||
} elseif ($double_encode) {
|
||||
return 'htmlspecialchars('
|
||||
. $params[0] . ', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ')';
|
||||
} else {
|
||||
// fall back to modifier.escape.php
|
||||
}
|
||||
|
||||
case 'htmlall':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if ($_double_encode) {
|
||||
// php >=5.2.3 - go native
|
||||
return 'mb_convert_encoding(htmlspecialchars('
|
||||
. $params[0] . ', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ', '
|
||||
. var_export($double_encode, true)
|
||||
. '), "HTML-ENTITIES", '
|
||||
. var_export($char_set, true) . ')';
|
||||
} elseif ($double_encode) {
|
||||
// php <5.2.3 - only handle double encoding
|
||||
return 'mb_convert_encoding(htmlspecialchars('
|
||||
. $params[0] . ', ENT_QUOTES, '
|
||||
. var_export($char_set, true)
|
||||
. '), "HTML-ENTITIES", '
|
||||
. var_export($char_set, true) . ')';
|
||||
} else {
|
||||
// fall back to modifier.escape.php
|
||||
}
|
||||
}
|
||||
|
||||
// no MBString fallback
|
||||
if ($_double_encode) {
|
||||
// php >=5.2.3 - go native
|
||||
return 'htmlentities('
|
||||
. $params[0] . ', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ', '
|
||||
. var_export($double_encode, true) . ')';
|
||||
} elseif ($double_encode) {
|
||||
// php <5.2.3 - only handle double encoding
|
||||
return 'htmlentities('
|
||||
. $params[0] . ', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ')';
|
||||
} else {
|
||||
// fall back to modifier.escape.php
|
||||
}
|
||||
|
||||
case 'url':
|
||||
return 'rawurlencode(' . $params[0] . ')';
|
||||
|
||||
case 'urlpathinfo':
|
||||
return 'str_replace("%2F", "/", rawurlencode(' . $params[0] . '))';
|
||||
|
||||
case 'quotes':
|
||||
// escape unescaped single quotes
|
||||
return 'preg_replace("%(?<!\\\\\\\\)\'%", "\\\'",' . $params[0] . ')';
|
||||
|
||||
case 'javascript':
|
||||
// escape quotes and backslashes, newlines, etc.
|
||||
return 'strtr(' . $params[0] . ', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/" ))';
|
||||
}
|
||||
}
|
||||
catch (SmartyException $e) {
|
||||
// pass through to regular plugin fallback
|
||||
}
|
||||
|
||||
// could not optimize |escape call, so fallback to regular plugin
|
||||
if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) {
|
||||
$compiler->template->required_plugins['nocache']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'modifier.escape.php';
|
||||
$compiler->template->required_plugins['nocache']['escape']['modifier']['function'] = 'smarty_modifier_escape';
|
||||
} else {
|
||||
$compiler->template->required_plugins['compiled']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'modifier.escape.php';
|
||||
$compiler->template->required_plugins['compiled']['escape']['modifier']['function'] = 'smarty_modifier_escape';
|
||||
}
|
||||
|
||||
return 'smarty_modifier_escape(' . join(', ', $params) . ')';
|
||||
}
|
||||
|
|
|
@ -1,34 +1,33 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty from_charset modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: from_charset<br>
|
||||
* Purpose: convert character encoding from $charset to internal encoding
|
||||
*
|
||||
* @author Rodney Rehm
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_from_charset($params, $compiler)
|
||||
{
|
||||
if (!Smarty::$_MBSTRING) {
|
||||
// FIXME: (rodneyrehm) shouldn't this throw an error?
|
||||
return $params[0];
|
||||
}
|
||||
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = '"ISO-8859-1"';
|
||||
}
|
||||
|
||||
return 'mb_convert_encoding(' . $params[0] . ', "' . addslashes(Smarty::$_CHARSET) . '", ' . $params[1] . ')';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty from_charset modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: from_charset<br>
|
||||
* Purpose: convert character encoding from $charset to internal encoding
|
||||
*
|
||||
* @author Rodney Rehm
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_from_charset($params)
|
||||
{
|
||||
if (!Smarty::$_MBSTRING) {
|
||||
// FIXME: (rodneyrehm) shouldn't this throw an error?
|
||||
return $params[0];
|
||||
}
|
||||
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = '"ISO-8859-1"';
|
||||
}
|
||||
|
||||
return 'mb_convert_encoding(' . $params[0] . ', "' . addslashes(Smarty::$_CHARSET) . '", ' . $params[1] . ')';
|
||||
}
|
||||
|
|
|
@ -1,32 +1,33 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty indent modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: indent<br>
|
||||
* Purpose: indent lines of text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.indent.php indent (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
|
||||
function smarty_modifiercompiler_indent($params, $compiler)
|
||||
{
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = 4;
|
||||
}
|
||||
if (!isset($params[2])) {
|
||||
$params[2] = "' '";
|
||||
}
|
||||
return 'preg_replace(\'!^!m\',str_repeat(' . $params[2] . ',' . $params[1] . '),' . $params[0] . ')';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty indent modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: indent<br>
|
||||
* Purpose: indent lines of text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.indent.php indent (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
|
||||
function smarty_modifiercompiler_indent($params)
|
||||
{
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = 4;
|
||||
}
|
||||
if (!isset($params[2])) {
|
||||
$params[2] = "' '";
|
||||
}
|
||||
|
||||
return 'preg_replace(\'!^!m\',str_repeat(' . $params[2] . ',' . $params[1] . '),' . $params[0] . ')';
|
||||
}
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty lower modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: lower<br>
|
||||
* Purpose: convert string to lowercase
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.lower.php lower (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
|
||||
function smarty_modifiercompiler_lower($params, $compiler)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strtolower(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')' ;
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strtolower(' . $params[0] . ')';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty lower modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: lower<br>
|
||||
* Purpose: convert string to lowercase
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.lower.php lower (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
|
||||
function smarty_modifiercompiler_lower($params)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strtolower(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strtolower(' . $params[0] . ')';
|
||||
}
|
||||
|
|
|
@ -1,25 +1,21 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty noprint modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: noprint<br>
|
||||
* Purpose: return an empty string
|
||||
*
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_noprint($params, $compiler)
|
||||
{
|
||||
return "''";
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty noprint modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: noprint<br>
|
||||
* Purpose: return an empty string
|
||||
*
|
||||
* @author Uwe Tews
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_noprint()
|
||||
{
|
||||
return "''";
|
||||
}
|
||||
|
|
|
@ -1,26 +1,25 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty string_format modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: string_format<br>
|
||||
* Purpose: format strings via sprintf
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_string_format($params, $compiler)
|
||||
{
|
||||
return 'sprintf(' . $params[1] . ',' . $params[0] . ')';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty string_format modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: string_format<br>
|
||||
* Purpose: format strings via sprintf
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_string_format($params)
|
||||
{
|
||||
return 'sprintf(' . $params[1] . ',' . $params[0] . ')';
|
||||
}
|
||||
|
|
|
@ -1,33 +1,33 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty strip modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: strip<br>
|
||||
* Purpose: Replace all repeated spaces, newlines, tabs
|
||||
* with a single space or supplied replacement string.<br>
|
||||
* Example: {$var|strip} {$var|strip:" "}<br>
|
||||
* Date: September 25th, 2002
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
|
||||
function smarty_modifiercompiler_strip($params, $compiler)
|
||||
{
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = "' '";
|
||||
}
|
||||
return "preg_replace('!\s+!" . Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})";
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty strip modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: strip<br>
|
||||
* Purpose: Replace all repeated spaces, newlines, tabs
|
||||
* with a single space or supplied replacement string.<br>
|
||||
* Example: {$var|strip} {$var|strip:" "}<br>
|
||||
* Date: September 25th, 2002
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
|
||||
function smarty_modifiercompiler_strip($params)
|
||||
{
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = "' '";
|
||||
}
|
||||
|
||||
return "preg_replace('!\s+!" . Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})";
|
||||
}
|
||||
|
|
|
@ -1,33 +1,29 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty strip_tags modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: strip_tags<br>
|
||||
* Purpose: strip html tags from text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.strip.tags.php strip_tags (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_strip_tags($params, $compiler)
|
||||
{
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = true;
|
||||
}
|
||||
if ($params[1] === true) {
|
||||
return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})";
|
||||
} else {
|
||||
return 'strip_tags(' . $params[0] . ')';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty strip_tags modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: strip_tags<br>
|
||||
* Purpose: strip html tags from text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.strip.tags.php strip_tags (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_strip_tags($params)
|
||||
{
|
||||
if (!isset($params[1]) || $params[1] === true || trim($params[1], '"') == 'true') {
|
||||
return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})";
|
||||
} else {
|
||||
return 'strip_tags(' . $params[0] . ')';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,34 +1,33 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty to_charset modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: to_charset<br>
|
||||
* Purpose: convert character encoding from internal encoding to $charset
|
||||
*
|
||||
* @author Rodney Rehm
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_to_charset($params, $compiler)
|
||||
{
|
||||
if (!Smarty::$_MBSTRING) {
|
||||
// FIXME: (rodneyrehm) shouldn't this throw an error?
|
||||
return $params[0];
|
||||
}
|
||||
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = '"ISO-8859-1"';
|
||||
}
|
||||
|
||||
return 'mb_convert_encoding(' . $params[0] . ', ' . $params[1] . ', "' . addslashes(Smarty::$_CHARSET) . '")';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty to_charset modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: to_charset<br>
|
||||
* Purpose: convert character encoding from internal encoding to $charset
|
||||
*
|
||||
* @author Rodney Rehm
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_to_charset($params)
|
||||
{
|
||||
if (!Smarty::$_MBSTRING) {
|
||||
// FIXME: (rodneyrehm) shouldn't this throw an error?
|
||||
return $params[0];
|
||||
}
|
||||
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = '"ISO-8859-1"';
|
||||
}
|
||||
|
||||
return 'mb_convert_encoding(' . $params[0] . ', ' . $params[1] . ', "' . addslashes(Smarty::$_CHARSET) . '")';
|
||||
}
|
||||
|
|
|
@ -1,51 +1,50 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty unescape modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: unescape<br>
|
||||
* Purpose: unescape html entities
|
||||
*
|
||||
* @author Rodney Rehm
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_unescape($params, $compiler)
|
||||
{
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = 'html';
|
||||
}
|
||||
if (!isset($params[2])) {
|
||||
$params[2] = '\'' . addslashes(Smarty::$_CHARSET) . '\'';
|
||||
} else {
|
||||
$params[2] = "'" . $params[2] . "'";
|
||||
}
|
||||
|
||||
switch (trim($params[1], '"\'')) {
|
||||
case 'entity':
|
||||
case 'htmlall':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_convert_encoding(' . $params[0] . ', ' . $params[2] . ', \'HTML-ENTITIES\')';
|
||||
}
|
||||
|
||||
return 'html_entity_decode(' . $params[0] . ', ENT_NOQUOTES, ' . $params[2] . ')';
|
||||
|
||||
case 'html':
|
||||
return 'htmlspecialchars_decode(' . $params[0] . ', ENT_QUOTES)';
|
||||
|
||||
case 'url':
|
||||
return 'rawurldecode(' . $params[0] . ')';
|
||||
|
||||
default:
|
||||
return $params[0];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty unescape modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: unescape<br>
|
||||
* Purpose: unescape html entities
|
||||
*
|
||||
* @author Rodney Rehm
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_unescape($params)
|
||||
{
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = 'html';
|
||||
}
|
||||
if (!isset($params[2])) {
|
||||
$params[2] = '\'' . addslashes(Smarty::$_CHARSET) . '\'';
|
||||
} else {
|
||||
$params[2] = "'" . $params[2] . "'";
|
||||
}
|
||||
|
||||
switch (trim($params[1], '"\'')) {
|
||||
case 'entity':
|
||||
case 'htmlall':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_convert_encoding(' . $params[0] . ', ' . $params[2] . ', \'HTML-ENTITIES\')';
|
||||
}
|
||||
|
||||
return 'html_entity_decode(' . $params[0] . ', ENT_NOQUOTES, ' . $params[2] . ')';
|
||||
|
||||
case 'html':
|
||||
return 'htmlspecialchars_decode(' . $params[0] . ', ENT_QUOTES)';
|
||||
|
||||
case 'url':
|
||||
return 'rawurldecode(' . $params[0] . ')';
|
||||
|
||||
default:
|
||||
return $params[0];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,30 +1,29 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty upper modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: lower<br>
|
||||
* Purpose: convert string to uppercase
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.upper.php lower (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
* @param array $params parameters
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_upper($params, $compiler)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strtoupper(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')' ;
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strtoupper(' . $params[0] . ')';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty upper modifier plugin
|
||||
* Type: modifier<br>
|
||||
* Name: lower<br>
|
||||
* Purpose: convert string to uppercase
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.upper.php lower (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_upper($params)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strtoupper(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strtoupper(' . $params[0] . ')';
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue