diff --git a/.htaccess b/.htaccess index 83d67e8f89..1b63f9ad6f 100644 --- a/.htaccess +++ b/.htaccess @@ -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] diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000000..33a1c58bb8 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,126 @@ +Version 3.3.2 + + Set default value for all not-null fields (fixes SQL warinigs) (annando) + Fix item filters in network page (issue #1222) (fabrixxm) + Remove reference to an ex Friendica hub from documentation (beardyunixer, tobiasd) + API throttling (annando) + Use a san-serif font in breathe style of vier theme (silke) + Prevent BBCode parsing problems with URLs (annando) + Add back tags to posts to Diaspora (annando) + Better display of pictures in posts (annando) + Fix out of control gprobe process (annando) + +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 + + API + added support in the API to allow image uploads from Twidere + support for the diaspora app in Firefox + + Themes + Stopped support of unmaintained themes. They will continue to work if enabled but are no longer displayed in the list of themes. + Merged all "zero" themes into a theme with variations. + new default avatar by Andi Stadler + + Usability + network page as default page after login + sections on users' settings page are now collapsable + automatic updating the network stream was improved + + Interaction + ignoring of threads + for selected contects one can now get notifications when they post something, useful e.g. for forums + After a new friendica contact is added, the user is directed to the contact page of the new contact. (Instead of the remote profile) + many improvement on all connectors, new app.net connector + the algorithm for shortening postings when posting to limited platforms was improved + improvements for the remote_self functionality for RSS/Atom feeds were done + + System stuff + no more apc support due problems with PHP 5.5 + privacy image cache moved from an addon into the core + updated the following libraries: smarty 3.1.19, fullcalendar 1.6.4, jquery 1.11, jgrowl 1.3.0 + added modernizer 2.8.3, better browser support + updates to the DB structure for better performance + preperations to use PDO in a later release + new notification system + web interface translations updated, addon translations now also possible separately from the main UI and done for CS, IT, RO, DE + vagrant support added for developers + some bugs were fixed for the profile import function + BBCode handling and reformatting to e.g. markdown was improved + Internal PusH server for communication with OStatus contacts + + Addons + translation now done at transifex as well + "newmemberwidget" adds widget with help links + welcome message to sidebar of network tab for new members + new statistics addon to take part in the Diaspora* survey + new bidirectional connector for app.net + new relay connector for Diaspora* + new connector for the buffer service + improvements for the connectors with Twitter, StatusNet/GNU Social, pump.io, google+ and facebook + improvements to the cal and jappix-mini addons + + Change in the structure of the git repo + The "master" branch will now contain stable stuff and hotfixes. + The new "develop" branch will contain the latest changes. + +Version 3.2 + + LICENSE change from Friendica uses now the AGPL + Language updates: PT_BR, RU, NB_NO, DE, PL, CS, ZH-CN, IT, CA, FR, NL + new languages: BG + added a README.translate and updates to the translation utils + addons are now translated separately + Theme updates: vier, smoothly, diabook, decaf-mobile, dispy, frost, frost-mobile, quattro + Bug fixes: #516, #517, #525, #476, #540, #546, #712, #728 + sample nginx and lighttpd config + new default templating engine: smarty3 + new share element + maintenance mode for longer running upgrade tasks + small fixed + edit profile photo link + better caching of pictures + threadening for outgoing emails + mail import + oembed thumbnails + SN subscriptions & more SN like behaviour if snautofollow addon is used + collect content of SN discussion threads + communication with Diaspora* + usage of the API + search improvements + MIME types for attachments + support Open Graph and Dublin Core when showing single items + better use of APC if present + use https versions of videos from youtube and vimeo to make firefox happy + fixes to the documentation + if a home.html is there, home.css is used as well + update included TinyMCE to version 3.5.8, fancybox + made more options available in the admin panel that were hidden before + show the admin information about when accounts expire in the admin panel + improving the install.php script + addons now can be members only + item object now contains the "edited" information left for the theme designers to show this info in a pretty way + improvments to the user-import from exported account files + It's now possible to authenticate an ejabberd server against friendica. + bugtracker moved to github + improvements to MySQL queries + +Version 3.1 + + See http://friendica.com/node/58 diff --git a/Vagrantfile b/Vagrantfile index 755cf202b4..48af4ae518 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -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 @@ -97,167 +40,20 @@ Vagrant.configure("2") do |config| # 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 diff --git a/boot.php b/boot.php index 5ef24f4944..34836a97aa 100644 --- a/boot.php +++ b/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.2' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1173 ); +define ( 'DB_UPDATE_VERSION', 1175 ); define ( 'EOL', "
\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 $class 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 "
"; 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) {
diff --git a/changelist.txt b/changelist.txt
deleted file mode 100644
index 95c5abd270..0000000000
--- a/changelist.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-Friendica 3.2
-------------
-
-* LICENSE change from Friendica uses now the AGPL
-* Language updates: PT_BR, RU, NB_NO, DE, PL, CS, ZH-CN, IT, CA, FR, NL
-* new languages: BG
-* added a README.translate and updates to the translation utils
-* addons are now translated separately
-* Theme updates: vier, smoothly, diabook, decaf-mobile, dispy, frost, frost-mobile, quattro
-* Bug fixes: #516, #517, #525, #476, #540, #546, #712, #728
-* sample nginx and lighttpd config
-* new default templating engine: smarty3
-* new share element
-* maintenance mode for longer running upgrade tasks
-* small fixed
-    * edit profile photo link
-    * better caching of pictures
-    * threadening for outgoing emails
-    * mail import
-    * oembed thumbnails
-    * SN subscriptions & more SN like behaviour if snautofollow addon is used
-    * collect content of SN discussion threads
-    * communication with Diaspora*
-    * usage of the API
-    * search improvements
-    * MIME types for attachments
-    * support Open Graph and Dublin Core when showing single items
-    * better use of APC if present
-    * use https versions of videos from youtube and vimeo to make firefox happy
-* fixes to the documentation
-* if a home.html is there, home.css is used as well
-* update included TinyMCE to version 3.5.8, fancybox
-* made more options available in the admin panel that were hidden before
-* show the admin information about when accounts expire in the admin panel
-* improving the install.php script
-* addons now can be members only
-* item object now contains the "edited" information left for the theme designers to show this info in a pretty way
-* improvments to the user-import from exported account files
-* It's now possible to authenticate an ejabberd server against friendica.
-* bugtracker moved to github
-* improvements to MySQL queries
-
diff --git a/doc/FAQ.md b/doc/FAQ.md
index c3c3e8bc24..6fa852e0b0 100644
--- a/doc/FAQ.md
+++ b/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
 
+
+
+**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).
+
 
 
 **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
 
 
 
 **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/) 
\ No newline at end of file
+If you are searching for new themes, you can find them at [Friendica-Themes.com](http://friendica-themes.com/) 
diff --git a/doc/Home.md b/doc/Home.md
index 86a4eb6473..6020f2c01c 100644
--- a/doc/Home.md
+++ b/doc/Home.md
@@ -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**
diff --git a/doc/Improve-Performance.md b/doc/Improve-Performance.md
index ceed6fcabc..d4c94d2d11 100644
--- a/doc/Improve-Performance.md
+++ b/doc/Improve-Performance.md
@@ -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.
diff --git a/doc/Install.md b/doc/Install.md
index 4ef1e40e53..28b8ba9f7e 100644
--- a/doc/Install.md
+++ b/doc/Install.md
@@ -47,7 +47,7 @@ you might have trouble getting everything to work.]
         
         `mkdir view/smarty3`
         
-        `chown 777 view/smarty3`
+        `chmod 777 view/smarty3`
     
     - For installing addons
     
diff --git a/doc/Making-Friends.md b/doc/Making-Friends.md
index 70b87abbc0..e0b1a254e0 100644
--- a/doc/Making-Friends.md
+++ b/doc/Making-Friends.md
@@ -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 New Here 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:
 
diff --git a/doc/andfinally.md b/doc/andfinally.md
index c4e8cb9480..f7aeb1bd45 100644
--- a/doc/andfinally.md
+++ b/doc/andfinally.md
@@ -7,12 +7,8 @@ Here are some more things to help get you started:
 **Groups**
 
 
-- New Here - a group for people new to Friendica
-
 - Friendica Support - problems?  This is the place to ask.
 
-- Public Stream - a place to talk about anything to anyone.
-
 - Let's Talk a group for finding people and groups who share similar interests.
 
 - Local Friendica a page for local Friendica groups
diff --git a/doc/api.md b/doc/api.md
new file mode 100644
index 0000000000..f36a79a5eb
--- /dev/null
+++ b/doc/api.md
@@ -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.
\ No newline at end of file
diff --git a/doc/de/Home.md b/doc/de/Home.md
index fee7b6a58b..0fd5634cc3 100644
--- a/doc/de/Home.md
+++ b/doc/de/Home.md
@@ -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**
diff --git a/doc/de/Improve-Performance.md b/doc/de/Improve-Performance.md
index fe99123342..346c76fc3e 100644
--- a/doc/de/Improve-Performance.md
+++ b/doc/de/Improve-Performance.md
@@ -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.
diff --git a/doc/de/Making-Friends.md b/doc/de/Making-Friends.md
index e6725228ff..74f1f62b37 100644
--- a/doc/de/Making-Friends.md
+++ b/doc/de/Making-Friends.md
@@ -5,9 +5,7 @@ Freunde finden
 
 Freundschaft kann in Friendica viele verschiedene Bedeutungen annehmen. Aber lasst es uns einfach halten, du willst einfach mit jemandem befreundet sein. Wie machst du das?
 
-Der einfachste Weg, um das zu machen, ist es, der Gruppe Neu hier beizutreten. Diese Gruppe ist speziell für Leute, die neu im Friendica-Netzwerk sind. Verbinde dich einfach mit der Gruppe, schreibe auf die "Wall" und lerne neue Leute kennen. Du musst uns nicht einmal direkt "liken" - kommentiere einige Beiträge und andere Leute werden anfangen, dich hinzuzufügen.
-
-Als Nächstes kannst du dir das Verzeichnis anschauen. Das Verzeichnis ist in zwei Teile aufgeteilt. Wenn du auf den "Verzeichnis"-Button klickst, wirst du zunächst alle Mitglieder deines Servers sehen, die sich dazu entschlossen haben, angezeigt zu werden. Außerdem siehst du dort einen Link zum globalen Verzeichnis. Wenn du dich durch das globale Verzeichnis klickst, siehst du alle Nutzer weltweit auf allen Servern, die sich entschlossen haben, im Verzeichnis zu erscheinen. Du wirst außerdem den Link "Show Community Forums" sehen, welcher dich zu Gruppen, Foren und Fan-Seiten führt. Du verbindest dich mit Personen, Gruppen und Foren auf die gleiche Art, wobei Gruppen und Foren deine Anfrage automatisch annehmen, wohingegen ein Mensch dich erst manuell bestätigen muss.
+Schau dir das Verzeichnis an. Das Verzeichnis ist in zwei Teile aufgeteilt. Wenn du auf den "Verzeichnis"-Button klickst, wirst du zunächst alle Mitglieder deines Servers sehen, die sich dazu entschlossen haben, angezeigt zu werden. Außerdem siehst du dort einen Link zum globalen Verzeichnis. Wenn du dich durch das globale Verzeichnis klickst, siehst du alle Nutzer weltweit auf allen Servern, die sich entschlossen haben, im Verzeichnis zu erscheinen. Du wirst außerdem den Link "Show Community Forums" sehen, welcher dich zu Gruppen, Foren und Fan-Seiten führt. Du verbindest dich mit Personen, Gruppen und Foren auf die gleiche Art, wobei Gruppen und Foren deine Anfrage automatisch annehmen, wohingegen ein Mensch dich erst manuell bestätigen muss.
 
 *Mit anderen Friendica-Nutzern verbinden*
 
diff --git a/doc/de/Quick-Start-andfinally.md b/doc/de/Quick-Start-andfinally.md
index 06a1878ba9..b6e492ae69 100644
--- a/doc/de/Quick-Start-andfinally.md
+++ b/doc/de/Quick-Start-andfinally.md
@@ -8,12 +8,8 @@ Hier sind noch einige weitere Dinge, die dir den Start vereinfachen können.
 **Gruppen**
 
 
-- Neu hier? - eine Gruppe für Leute, die neu bei Friendica sind
-
 - Friendica Support - Probleme?  Dann ist das der Platz, um zu fragen!
 
-- Öffentlicher Stream - ein Platz, um über alles mit jedem zu reden.
-
 - Let's Talk eine Gruppe, um Leute und Gruppen mit gleichen Interessen zu finden 
 
 - Local Friendica eine Seite für lokale Friendica-Gruppen
diff --git a/doc/de/andfinally.md b/doc/de/andfinally.md
index 06a1878ba9..b6e492ae69 100644
--- a/doc/de/andfinally.md
+++ b/doc/de/andfinally.md
@@ -8,12 +8,8 @@ Hier sind noch einige weitere Dinge, die dir den Start vereinfachen können.
 **Gruppen**
 
 
-- Neu hier? - eine Gruppe für Leute, die neu bei Friendica sind
-
 - Friendica Support - Probleme?  Dann ist das der Platz, um zu fragen!
 
-- Öffentlicher Stream - ein Platz, um über alles mit jedem zu reden.
-
 - Let's Talk eine Gruppe, um Leute und Gruppen mit gleichen Interessen zu finden 
 
 - Local Friendica eine Seite für lokale Friendica-Gruppen
diff --git a/doc/readme.md b/doc/readme.md
new file mode 100644
index 0000000000..6020f2c01c
--- /dev/null
+++ b/doc/readme.md
@@ -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)
+
diff --git a/doc/translations.md b/doc/translations.md
new file mode 100644
index 0000000000..b874e9ea2e
--- /dev/null
+++ b/doc/translations.md
@@ -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/
+
diff --git a/htconfig.php b/htconfig.php
index a5f5574eea..4208924cfd 100644
--- a/htconfig.php
+++ b/htconfig.php
@@ -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
diff --git a/images/person-175.jpg b/images/person-175.jpg
index fc0ec3d771..527a9d78b6 100644
Binary files a/images/person-175.jpg and b/images/person-175.jpg differ
diff --git a/images/person-48.jpg b/images/person-48.jpg
index dc5eb6e692..8984bb2955 100644
Binary files a/images/person-48.jpg and b/images/person-48.jpg differ
diff --git a/images/person-80.jpg b/images/person-80.jpg
index 75b8faf922..4e70a4dde1 100644
Binary files a/images/person-80.jpg and b/images/person-80.jpg differ
diff --git a/include/EmailNotification.php b/include/Emailer.php
similarity index 64%
rename from include/EmailNotification.php
rename to include/Emailer.php
index 8861e8f5d8..535a054289 100644
--- a/include/EmailNotification.php
+++ b/include/Emailer.php
@@ -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;
 	}
 }
-?>
\ No newline at end of file
+?>
diff --git a/include/api.php b/include/api.php
index ade783662b..ffa5d0e9df 100644
--- a/include/api.php
+++ b/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");
@@ -666,6 +681,7 @@
 			logger('api_statuses_update: no user');
 			return false;
 		}
+
 		$user_info = api_get_user($a);
 
 		// convert $_POST array items to the form we use for web posts.
@@ -710,8 +726,64 @@
 		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");
+			// Check for throttling (maximum posts per day, week and month)
+			$throttle_day = get_config('system','throttle_limit_day');
+			if ($throttle_day > 0) {
+				$datefrom = date("Y-m-d H:i:s", time() - 24*60*60);
+
+				$r = q("SELECT COUNT(*) AS `posts_day` FROM `item` WHERE `uid`=%d AND `wall`
+					AND `created` > '%s' AND `id` = `parent`",
+					intval(api_user()), dbesc($datefrom));
+
+				if ($r)
+					$posts_day = $r[0]["posts_day"];
+				else
+					$posts_day = 0;
+
+				if ($posts_day > $throttle_day) {
+					logger('Daily posting limit reached for user '.api_user(), LOGGER_DEBUG);
+					die(api_error($a, $type, sprintf(t("Daily posting limit of %d posts reached. The post was rejected."), $throttle_day)));
+				}
+			}
+
+			$throttle_week = get_config('system','throttle_limit_week');
+			if ($throttle_week > 0) {
+				$datefrom = date("Y-m-d H:i:s", time() - 24*60*60*7);
+
+				$r = q("SELECT COUNT(*) AS `posts_week` FROM `item` WHERE `uid`=%d AND `wall`
+					AND `created` > '%s' AND `id` = `parent`",
+					intval(api_user()), dbesc($datefrom));
+
+				if ($r)
+					$posts_week = $r[0]["posts_week"];
+				else
+					$posts_week = 0;
+
+				if ($posts_week > $throttle_week) {
+					logger('Weekly posting limit reached for user '.api_user(), LOGGER_DEBUG);
+					die(api_error($a, $type, sprintf(t("Weekly posting limit of %d posts reached. The post was rejected."), $throttle_week)));
+				}
+			}
+
+			$throttle_month = get_config('system','throttle_limit_month');
+			if ($throttle_month > 0) {
+				$datefrom = date("Y-m-d H:i:s", time() - 24*60*60*30);
+
+				$r = q("SELECT COUNT(*) AS `posts_month` FROM `item` WHERE `uid`=%d AND `wall`
+					AND `created` > '%s' AND `id` = `parent`",
+					intval(api_user()), dbesc($datefrom));
+
+				if ($r)
+					$posts_month = $r[0]["posts_month"];
+				else
+					$posts_month = 0;
+
+				if ($posts_month > $throttle_month) {
+					logger('Monthly posting limit reached for user '.api_user(), LOGGER_DEBUG);
+					die(api_error($a, $type, sprintf(t("Monthly posting limit of %d posts reached. The post was rejected."), $throttle_month)));
+				}
+			}
+
 			$_REQUEST['type'] = 'wall';
 			if(x($_FILES,'media')) {
 				// upload the image if we have one
@@ -727,6 +799,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 +1011,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 +1376,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 +1466,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 +1897,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 +1965,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 +1999,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 +2321,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 +2330,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 +2365,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 +2385,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 +2487,6 @@
 
 
 
-
-
-
 function api_share_as_retweet($a, $uid, &$item) {
 	$body = trim($item["body"]);
 
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index 39742291fd..7107c49139 100644
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
@@ -56,6 +56,8 @@ function diaspora2bb($s) {
 
 function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) {
 
+	$OriginalText = $Text;
+
 	// Since Diaspora is creating a summary for links, this function removes them before posting
 	if ($fordiaspora)
 		$Text = bb_remove_share_information($Text);
@@ -73,12 +75,24 @@ function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) {
 	$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $Text);
 
 	// Convert it to HTML - don't try oembed
-	if ($fordiaspora)
+	if ($fordiaspora) {
 		$Text = bbcode($Text, $preserve_nl, false, 3);
-	else {
+
+		// Add all tags that maybe were removed
+		if (preg_match_all("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",$OriginalText, $tags)) {
+			$tagline = "";
+			foreach($tags[2] as $tag)
+				if (!strpos($Text, "#".$tag))
+					$tagline .= "#".$tag." ";
+
+			$Text = $Text."
".$tagline; + } + + } else { $Text = bbcode($Text, $preserve_nl, false, 4); + // Libertree doesn't convert a harizontal rule if there isn't a linefeed - $Text = str_replace("
", "

", $Text); + $Text = str_replace(array("
", "
"), array("

", "

"), $Text); } // Now convert HTML to Markdown diff --git a/include/bbcode.php b/include/bbcode.php index 017673423b..724b8e2fdd 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -3,10 +3,10 @@ require_once("include/oembed.php"); require_once('include/event.php'); function bb_attachment($Text, $plaintext = false, $tryoembed = true) { - $Text = preg_replace_callback("/\[attachment(.*?)\](.*?)\[\/attachment\]/ism", + $Text = preg_replace_callback("/(.*?)\[attachment(.*?)\](.*?)\[\/attachment\]/ism", function ($match) use ($plaintext){ - $attributes = $match[1]; + $attributes = $match[2]; $type = ""; preg_match("/type='(.*?)'/ism", $attributes, $matches); @@ -65,8 +65,13 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) { $preview = $matches[1]; } + if (((strpos($match[1], "[img=") !== false) OR (strpos($match[1], "[img]") !== false)) AND ($image != "")) { + $preview = $image; + $image = ""; + } + if ($plaintext) - $text = sprintf('%s', $url, $title); + $text = sprintf('%s
', $url, $title); else { $text = sprintf('', $type); @@ -83,44 +88,15 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) { $text .= $oembed; - $text .= sprintf('
%s
', trim($match[2])); + $text .= sprintf('
%s
', trim($match[3])); } - return($text); + return($match[1].$text); },$Text); 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 +187,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 +511,14 @@ function bb_ShareAttributes($share, $simplehtml) { if ($text != "") $text .= "
"; - $text .= $headline.'
'.trim($share[3])."

"; + if (substr(normalise_link($link), 0, 19) != "http://twitter.com/") { + $text .= $headline.'
'.trim($share[3])."

"; + + if ($link != "") + $text .= '
[l]'; + } else + $text .= '
'.$link.''; - if ($link != "") - $text .= '
[l]'; break; case 4: $headline = '
'; @@ -674,10 +655,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 +705,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 +802,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 +818,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('
','
'), $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 diff --git a/include/datetime.php b/include/datetime.php index 3ad9ea3a10..f3236238fa 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -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; } } }} diff --git a/include/dba.php b/include/dba.php index 7409ec3a8c..c66723033c 100644 --- a/include/dba.php +++ b/include/dba.php @@ -1,10 +1,15 @@ 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')) { diff --git a/include/dbstructure.php b/include/dbstructure.php index 77482d41ba..66e67c0a9a 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -1,27 +1,70 @@ config['admin_email']))))."'"; + $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)", + $admin_mail_list + ); + + // every admin could had different language + + foreach ($adminlist as $admin) { + $lang = (($admin['language'])?$admin['language']:'en'); + push_lang($lang); + + $preamble = deindent(t(" + The friendica developers released update %s recently, + but when I tried to install it, something went terribly wrong. + This needs to be fixed soon and I can't do it alone. Please contact a + friendica developer if you can not help me on your own. My database might be invalid.")); + $body = t("The error message is\n[pre]%s[/pre]"); + $preamble = sprintf($preamble, $update_id); + $body = sprintf($body, $error_message); + + notification(array( + 'type' => "SYSTEM_EMAIL", + 'to_email' => $admin['email'], + 'preamble' => $preamble, + 'body' => $body, + 'language' => $lang, + )); } - if(is_null($db)) { - @include(".htconfig.php"); - require_once("include/dba.php"); - $db = new dba($db_host, $db_user, $db_pass, $db_data); - unset($db_host, $db_user, $db_pass, $db_data); - } - update_structure(true, true); + + + /* + $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; } -if (array_search(__file__,get_included_files())===0){ - dbstructure_run($argv,$argc); - killme(); -} function table_structure($table) { $structures = q("DESCRIBE `%s`", $table); @@ -49,7 +92,7 @@ function table_structure($table) { if ($field["Null"] == "NO") $fielddata[$field["Field"]]["not null"] = true; - if ($field["Default"] != "") + if (isset($field["Default"])) $fielddata[$field["Field"]]["default"] = $field["Default"]; if ($field["Extra"] != "") @@ -59,7 +102,6 @@ function table_structure($table) { $fielddata[$field["Field"]]["primary"] = true; } } - return(array("fields"=>$fielddata, "indexes"=>$indexdata)); } @@ -139,8 +181,8 @@ function update_structure($verbose, $action) { $sql3 .= ", ".$sql2; } else { // Compare the field definition - $current_field_definition = implode($database[$name]["fields"][$fieldname]); - $new_field_definition = implode($parameters); + $current_field_definition = implode(",",$database[$name]["fields"][$fieldname]); + $new_field_definition = implode(",",$parameters); if ($current_field_definition != $new_field_definition) { $sql2=db_modify_table_field($fieldname, $parameters); if ($sql3 == "") @@ -189,7 +231,7 @@ function db_field_command($parameters, $create = true) { if ($parameters["not null"]) $fieldstruct .= " NOT NULL"; - if ($parameters["default"] != "") + if (isset($parameters["default"])) $fieldstruct .= " DEFAULT '".$parameters["default"]."'"; if ($parameters["extra"] != "") @@ -267,8 +309,8 @@ function db_definition() { $database["addon"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "name" => array("type" => "varchar(255)", "not null" => "1"), - "version" => array("type" => "varchar(255)", "not null" => "1"), + "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"), @@ -281,11 +323,11 @@ function db_definition() { $database["attach"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "uid" => array("type" => "int(11)", "not null" => "1"), - "hash" => array("type" => "varchar(64)", "not null" => "1"), - "filename" => array("type" => "varchar(255)", "not null" => "1"), - "filetype" => array("type" => "varchar(64)", "not null" => "1"), - "filesize" => array("type" => "int(11)", "not null" => "1"), + "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""), + "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""), + "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "data" => array("type" => "longblob", "not null" => "1"), "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), @@ -301,10 +343,10 @@ function db_definition() { $database["auth_codes"] = array( "fields" => array( "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"), - "client_id" => array("type" => "varchar(20)", "not null" => "1"), - "redirect_uri" => array("type" => "varchar(200)", "not null" => "1"), - "expires" => array("type" => "int(11)", "not null" => "1"), - "scope" => array("type" => "varchar(250)", "not null" => "1"), + "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""), + "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""), + "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""), ), "indexes" => array( "PRIMARY" => array("id"), @@ -314,7 +356,7 @@ function db_definition() { "fields" => array( "k" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"), "v" => array("type" => "text", "not null" => "1"), - "updated" => array("type" => "datetime", "not null" => "1"), + "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), ), "indexes" => array( "PRIMARY" => array("k"), @@ -324,11 +366,11 @@ function db_definition() { $database["challenge"] = array( "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "challenge" => array("type" => "varchar(255)", "not null" => "1"), - "dfrn-id" => array("type" => "varchar(255)", "not null" => "1"), - "expire" => array("type" => "int(11)", "not null" => "1"), - "type" => array("type" => "varchar(255)", "not null" => "1"), - "last_update" => array("type" => "varchar(255)", "not null" => "1"), + "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), ), "indexes" => array( "PRIMARY" => array("id"), @@ -337,8 +379,8 @@ function db_definition() { $database["clients"] = array( "fields" => array( "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"), - "pw" => array("type" => "varchar(20)", "not null" => "1"), - "redirect_uri" => array("type" => "varchar(200)", "not null" => "1"), + "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""), + "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""), "name" => array("type" => "text"), "icon" => array("type" => "text"), "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), @@ -350,8 +392,8 @@ function db_definition() { $database["config"] = array( "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "cat" => array("type" => "varchar(255)", "not null" => "1"), - "k" => array("type" => "varchar(255)", "not null" => "1"), + "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "v" => array("type" => "text", "not null" => "1"), ), "indexes" => array( @@ -362,29 +404,29 @@ function db_definition() { $database["contact"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "uid" => array("type" => "int(11)", "not null" => "1"), + "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), - "network" => array("type" => "varchar(255)", "not null" => "1"), - "name" => array("type" => "varchar(255)", "not null" => "1"), - "nick" => array("type" => "varchar(255)", "not null" => "1"), - "attag" => array("type" => "varchar(255)", "not null" => "1"), + "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "photo" => array("type" => "text", "not null" => "1"), "thumb" => array("type" => "text", "not null" => "1"), "micro" => array("type" => "text", "not null" => "1"), "site-pubkey" => array("type" => "text", "not null" => "1"), - "issued-id" => array("type" => "varchar(255)", "not null" => "1"), - "dfrn-id" => array("type" => "varchar(255)", "not null" => "1"), - "url" => array("type" => "varchar(255)", "not null" => "1"), - "nurl" => array("type" => "varchar(255)", "not null" => "1"), - "addr" => array("type" => "varchar(255)", "not null" => "1"), - "alias" => array("type" => "varchar(255)", "not null" => "1"), + "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "pubkey" => array("type" => "text", "not null" => "1"), "prvkey" => array("type" => "text", "not null" => "1"), - "batch" => array("type" => "varchar(255)", "not null" => "1"), + "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "request" => array("type" => "text", "not null" => "1"), "notify" => array("type" => "text", "not null" => "1"), "poll" => array("type" => "text", "not null" => "1"), @@ -394,14 +436,14 @@ function db_definition() { "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), - "hub-verify" => array("type" => "varchar(255)", "not null" => "1"), + "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "last-update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "success_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "name-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "uri-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "term-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), - "priority" => array("type" => "tinyint(3)", "not null" => "1"), + "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"), "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"), "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), @@ -415,10 +457,11 @@ function db_definition() { "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"), "info" => array("type" => "mediumtext", "not null" => "1"), "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"), - "bdyear" => array("type" => "varchar(4)", "not null" => "1"), - "bd" => array("type" => "date", "not null" => "1"), + "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""), + "bd" => array("type" => "date", "not null" => "1", "default" => "0000-00-00"), "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), + "ffi_keyword_blacklist" => array("type" => "mediumtext", "not null" => "1"), ), "indexes" => array( "PRIMARY" => array("id"), @@ -428,10 +471,10 @@ function db_definition() { $database["conv"] = array( "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "guid" => array("type" => "varchar(64)", "not null" => "1"), + "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""), "recips" => array("type" => "mediumtext", "not null" => "1"), - "uid" => array("type" => "int(11)", "not null" => "1"), - "creator" => array("type" => "varchar(255)", "not null" => "1"), + "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "subject" => array("type" => "mediumtext", "not null" => "1"), @@ -444,9 +487,9 @@ function db_definition() { $database["deliverq"] = array( "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "cmd" => array("type" => "varchar(32)", "not null" => "1"), - "item" => array("type" => "int(11)", "not null" => "1"), - "contact" => array("type" => "int(11)", "not null" => "1"), + "cmd" => array("type" => "varchar(32)", "not null" => "1", "default" => ""), + "item" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "contact" => array("type" => "int(11)", "not null" => "1", "default" => "0"), ), "indexes" => array( "PRIMARY" => array("id"), @@ -455,9 +498,9 @@ function db_definition() { $database["dsprphotoq"] = array( "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "uid" => array("type" => "int(11)", "not null" => "1"), + "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "msg" => array("type" => "mediumtext", "not null" => "1"), - "attempt" => array("type" => "tinyint(4)", "not null" => "1"), + "attempt" => array("type" => "tinyint(4)", "not null" => "1", "default" => "0"), ), "indexes" => array( "PRIMARY" => array("id"), @@ -466,17 +509,17 @@ function db_definition() { $database["event"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "uid" => array("type" => "int(11)", "not null" => "1"), - "cid" => array("type" => "int(11)", "not null" => "1"), - "uri" => array("type" => "varchar(255)", "not null" => "1"), - "created" => array("type" => "datetime", "not null" => "1"), - "edited" => array("type" => "datetime", "not null" => "1"), - "start" => array("type" => "datetime", "not null" => "1"), - "finish" => array("type" => "datetime", "not null" => "1"), + "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), + "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), + "start" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), + "finish" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "summary" => array("type" => "text", "not null" => "1"), "desc" => array("type" => "text", "not null" => "1"), "location" => array("type" => "text", "not null" => "1"), - "type" => array("type" => "varchar(255)", "not null" => "1"), + "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"), "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"), @@ -493,19 +536,19 @@ function db_definition() { $database["fcontact"] = array( "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "url" => array("type" => "varchar(255)", "not null" => "1"), - "name" => array("type" => "varchar(255)", "not null" => "1"), - "photo" => array("type" => "varchar(255)", "not null" => "1"), - "request" => array("type" => "varchar(255)", "not null" => "1"), - "nick" => array("type" => "varchar(255)", "not null" => "1"), - "addr" => array("type" => "varchar(255)", "not null" => "1"), - "batch" => array("type" => "varchar(255)", "not null" => "1"), - "notify" => array("type" => "varchar(255)", "not null" => "1"), - "poll" => array("type" => "varchar(255)", "not null" => "1"), - "confirm" => array("type" => "varchar(255)", "not null" => "1"), - "priority" => array("type" => "tinyint(1)", "not null" => "1"), - "network" => array("type" => "varchar(32)", "not null" => "1"), - "alias" => array("type" => "varchar(255)", "not null" => "1"), + "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), + "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""), + "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "pubkey" => array("type" => "text", "not null" => "1"), "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), ), @@ -517,9 +560,9 @@ function db_definition() { $database["ffinder"] = array( "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "uid" => array("type" => "int(10) unsigned", "not null" => "1"), - "cid" => array("type" => "int(10) unsigned", "not null" => "1"), - "fid" => array("type" => "int(10) unsigned", "not null" => "1"), + "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), + "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), + "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), ), "indexes" => array( "PRIMARY" => array("id"), @@ -528,8 +571,8 @@ function db_definition() { $database["fserver"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "server" => array("type" => "varchar(255)", "not null" => "1"), - "posturl" => array("type" => "varchar(255)", "not null" => "1"), + "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "key" => array("type" => "text", "not null" => "1"), ), "indexes" => array( @@ -540,14 +583,14 @@ function db_definition() { $database["fsuggest"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "uid" => array("type" => "int(11)", "not null" => "1"), - "cid" => array("type" => "int(11)", "not null" => "1"), - "name" => array("type" => "varchar(255)", "not null" => "1"), - "url" => array("type" => "varchar(255)", "not null" => "1"), - "request" => array("type" => "varchar(255)", "not null" => "1"), - "photo" => array("type" => "varchar(255)", "not null" => "1"), + "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "note" => array("type" => "text", "not null" => "1"), - "created" => array("type" => "datetime", "not null" => "1"), + "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), ), "indexes" => array( "PRIMARY" => array("id"), @@ -556,8 +599,8 @@ function db_definition() { $database["gcign"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "uid" => array("type" => "int(11)", "not null" => "1"), - "gcid" => array("type" => "int(11)", "not null" => "1"), + "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), ), "indexes" => array( "PRIMARY" => array("id"), @@ -568,11 +611,11 @@ function db_definition() { $database["gcontact"] = array( "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "name" => array("type" => "varchar(255)", "not null" => "1"), - "url" => array("type" => "varchar(255)", "not null" => "1"), - "nurl" => array("type" => "varchar(255)", "not null" => "1"), - "photo" => array("type" => "varchar(255)", "not null" => "1"), - "connect" => array("type" => "varchar(255)", "not null" => "1"), + "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), ), "indexes" => array( "PRIMARY" => array("id"), @@ -582,11 +625,11 @@ function db_definition() { $database["glink"] = array( "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "cid" => array("type" => "int(11)", "not null" => "1"), - "uid" => array("type" => "int(11)", "not null" => "1"), - "gcid" => array("type" => "int(11)", "not null" => "1"), - "zcid" => array("type" => "int(11)", "not null" => "1"), - "updated" => array("type" => "datetime", "not null" => "1"), + "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), ), "indexes" => array( "PRIMARY" => array("id"), @@ -598,10 +641,10 @@ function db_definition() { $database["group"] = array( "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "uid" => array("type" => "int(10) unsigned", "not null" => "1"), + "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), - "name" => array("type" => "varchar(255)", "not null" => "1"), + "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), ), "indexes" => array( "PRIMARY" => array("id"), @@ -611,9 +654,9 @@ function db_definition() { $database["group_member"] = array( "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "uid" => array("type" => "int(10) unsigned", "not null" => "1"), - "gid" => array("type" => "int(10) unsigned", "not null" => "1"), - "contact-id" => array("type" => "int(10) unsigned", "not null" => "1"), + "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), + "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), + "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), ), "indexes" => array( "PRIMARY" => array("id"), @@ -623,7 +666,7 @@ function db_definition() { $database["guid"] = array( "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "guid" => array("type" => "varchar(255)", "not null" => "1"), + "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), ), "indexes" => array( "PRIMARY" => array("id"), @@ -633,9 +676,9 @@ function db_definition() { $database["hook"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "hook" => array("type" => "varchar(255)", "not null" => "1"), - "file" => array("type" => "varchar(255)", "not null" => "1"), - "function" => array("type" => "varchar(255)", "not null" => "1"), + "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"), ), "indexes" => array( @@ -646,14 +689,14 @@ function db_definition() { $database["intro"] = array( "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "uid" => array("type" => "int(10) unsigned", "not null" => "1"), + "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), - "contact-id" => array("type" => "int(11)", "not null" => "1"), - "knowyou" => array("type" => "tinyint(1)", "not null" => "1"), + "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "note" => array("type" => "text", "not null" => "1"), - "hash" => array("type" => "varchar(255)", "not null" => "1"), - "datetime" => array("type" => "datetime", "not null" => "1"), + "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "datetime" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"), "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), ), @@ -664,46 +707,46 @@ function db_definition() { $database["item"] = array( "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "guid" => array("type" => "varchar(255)", "not null" => "1"), - "uri" => array("type" => "varchar(255)", "not null" => "1"), + "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), - "contact-id" => array("type" => "int(11)", "not null" => "1"), - "type" => array("type" => "varchar(255)", "not null" => "1"), + "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), - "parent-uri" => array("type" => "varchar(255)", "not null" => "1"), - "extid" => array("type" => "varchar(255)", "not null" => "1"), - "thr-parent" => array("type" => "varchar(255)", "not null" => "1"), + "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), - "owner-name" => array("type" => "varchar(255)", "not null" => "1"), - "owner-link" => array("type" => "varchar(255)", "not null" => "1"), - "owner-avatar" => array("type" => "varchar(255)", "not null" => "1"), - "author-name" => array("type" => "varchar(255)", "not null" => "1"), - "author-link" => array("type" => "varchar(255)", "not null" => "1"), - "author-avatar" => array("type" => "varchar(255)", "not null" => "1"), - "title" => array("type" => "varchar(255)", "not null" => "1"), + "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "body" => array("type" => "mediumtext", "not null" => "1"), - "app" => array("type" => "varchar(255)", "not null" => "1"), - "verb" => array("type" => "varchar(255)", "not null" => "1"), - "object-type" => array("type" => "varchar(255)", "not null" => "1"), + "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "object" => array("type" => "text", "not null" => "1"), - "target-type" => array("type" => "varchar(255)", "not null" => "1"), + "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "target" => array("type" => "text", "not null" => "1"), "postopts" => array("type" => "text", "not null" => "1"), - "plink" => array("type" => "varchar(255)", "not null" => "1"), - "resource-id" => array("type" => "varchar(255)", "not null" => "1"), - "event-id" => array("type" => "int(11)", "not null" => "1"), + "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "tag" => array("type" => "mediumtext", "not null" => "1"), "attach" => array("type" => "mediumtext", "not null" => "1"), "inform" => array("type" => "mediumtext", "not null" => "1"), "file" => array("type" => "mediumtext", "not null" => "1"), - "location" => array("type" => "varchar(255)", "not null" => "1"), - "coord" => array("type" => "varchar(255)", "not null" => "1"), + "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "allow_cid" => array("type" => "mediumtext", "not null" => "1"), "allow_gid" => array("type" => "mediumtext", "not null" => "1"), "deny_cid" => array("type" => "mediumtext", "not null" => "1"), @@ -721,7 +764,7 @@ function db_definition() { "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"), "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), - "network" => array("type" => "varchar(32)", "not null" => "1"), + "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""), ), "indexes" => array( "PRIMARY" => array("id"), @@ -762,10 +805,10 @@ function db_definition() { $database["item_id"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "iid" => array("type" => "int(11)", "not null" => "1"), - "uid" => array("type" => "int(11)", "not null" => "1"), - "sid" => array("type" => "varchar(255)", "not null" => "1"), - "service" => array("type" => "varchar(255)", "not null" => "1"), + "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), ), "indexes" => array( "PRIMARY" => array("id"), @@ -778,7 +821,7 @@ function db_definition() { $database["locks"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "name" => array("type" => "varchar(128)", "not null" => "1"), + "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""), "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), ), "indexes" => array( @@ -788,21 +831,21 @@ function db_definition() { $database["mail"] = array( "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "uid" => array("type" => "int(10) unsigned", "not null" => "1"), - "guid" => array("type" => "varchar(64)", "not null" => "1"), - "from-name" => array("type" => "varchar(255)", "not null" => "1"), - "from-photo" => array("type" => "varchar(255)", "not null" => "1"), - "from-url" => array("type" => "varchar(255)", "not null" => "1"), - "contact-id" => array("type" => "varchar(255)", "not null" => "1"), - "convid" => array("type" => "int(11) unsigned", "not null" => "1"), - "title" => array("type" => "varchar(255)", "not null" => "1"), + "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), + "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""), + "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"), + "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "body" => array("type" => "mediumtext", "not null" => "1"), - "seen" => array("type" => "tinyint(1)", "not null" => "1"), + "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), - "replied" => array("type" => "tinyint(1)", "not null" => "1"), + "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), - "uri" => array("type" => "varchar(255)", "not null" => "1"), - "parent-uri" => array("type" => "varchar(255)", "not null" => "1"), + "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), ), "indexes" => array( @@ -818,16 +861,16 @@ function db_definition() { $database["mailacct"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "uid" => array("type" => "int(11)", "not null" => "1"), - "server" => array("type" => "varchar(255)", "not null" => "1"), - "port" => array("type" => "int(11)", "not null" => "1"), - "ssltype" => array("type" => "varchar(16)", "not null" => "1"), - "mailbox" => array("type" => "varchar(255)", "not null" => "1"), - "user" => array("type" => "varchar(255)", "not null" => "1"), + "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""), + "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "pass" => array("type" => "text", "not null" => "1"), - "reply_to" => array("type" => "varchar(255)", "not null" => "1"), - "action" => array("type" => "int(11)", "not null" => "1"), - "movetofolder" => array("type" => "varchar(255)", "not null" => "1"), + "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), ), @@ -838,8 +881,8 @@ function db_definition() { $database["manage"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "uid" => array("type" => "int(11)", "not null" => "1"), - "mid" => array("type" => "int(11)", "not null" => "1"), + "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), ), "indexes" => array( "PRIMARY" => array("id"), @@ -849,19 +892,19 @@ function db_definition() { $database["notify"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "hash" => array("type" => "varchar(64)", "not null" => "1"), - "type" => array("type" => "int(11)", "not null" => "1"), - "name" => array("type" => "varchar(255)", "not null" => "1"), - "url" => array("type" => "varchar(255)", "not null" => "1"), - "photo" => array("type" => "varchar(255)", "not null" => "1"), - "date" => array("type" => "datetime", "not null" => "1"), + "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""), + "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "msg" => array("type" => "mediumtext", "not null" => "1"), - "uid" => array("type" => "int(11)", "not null" => "1"), - "link" => array("type" => "varchar(255)", "not null" => "1"), - "parent" => array("type" => "int(11)", "not null" => "1"), + "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), - "verb" => array("type" => "varchar(255)", "not null" => "1"), - "otype" => array("type" => "varchar(16)", "not null" => "1"), + "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""), ), "indexes" => array( "PRIMARY" => array("id"), @@ -871,10 +914,10 @@ function db_definition() { $database["notify-threads"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "notify-id" => array("type" => "int(11)", "not null" => "1"), + "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), - "receiver-uid" => array("type" => "int(11)", "not null" => "1"), + "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), ), "indexes" => array( "PRIMARY" => array("id"), @@ -886,8 +929,8 @@ function db_definition() { "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), - "cat" => array("type" => "varchar(255)", "not null" => "1"), - "k" => array("type" => "varchar(255)", "not null" => "1"), + "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "v" => array("type" => "mediumtext", "not null" => "1"), ), "indexes" => array( @@ -898,22 +941,22 @@ function db_definition() { $database["photo"] = array( "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "uid" => array("type" => "int(10) unsigned", "not null" => "1"), + "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), - "guid" => array("type" => "varchar(64)", "not null" => "1"), - "resource-id" => array("type" => "varchar(255)", "not null" => "1"), - "created" => array("type" => "datetime", "not null" => "1"), - "edited" => array("type" => "datetime", "not null" => "1"), - "title" => array("type" => "varchar(255)", "not null" => "1"), + "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""), + "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), + "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), + "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "desc" => array("type" => "text", "not null" => "1"), - "album" => array("type" => "varchar(255)", "not null" => "1"), - "filename" => array("type" => "varchar(255)", "not null" => "1"), + "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"), - "height" => array("type" => "smallint(6)", "not null" => "1"), - "width" => array("type" => "smallint(6)", "not null" => "1"), + "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"), + "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"), "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), "data" => array("type" => "mediumblob", "not null" => "1"), - "scale" => array("type" => "tinyint(3)", "not null" => "1"), + "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"), "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "allow_cid" => array("type" => "mediumtext", "not null" => "1"), "allow_gid" => array("type" => "mediumtext", "not null" => "1"), @@ -930,7 +973,7 @@ function db_definition() { $database["poll"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "uid" => array("type" => "int(11)", "not null" => "1"), + "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "q0" => array("type" => "mediumtext", "not null" => "1"), "q1" => array("type" => "mediumtext", "not null" => "1"), "q2" => array("type" => "mediumtext", "not null" => "1"), @@ -950,8 +993,8 @@ function db_definition() { $database["poll_result"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "poll_id" => array("type" => "int(11)", "not null" => "1"), - "choice" => array("type" => "int(11)", "not null" => "1"), + "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"), ), "indexes" => array( "PRIMARY" => array("id"), @@ -962,32 +1005,32 @@ function db_definition() { $database["profile"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "uid" => array("type" => "int(11)", "not null" => "1"), - "profile-name" => array("type" => "varchar(255)", "not null" => "1"), + "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), - "name" => array("type" => "varchar(255)", "not null" => "1"), - "pdesc" => array("type" => "varchar(255)", "not null" => "1"), + "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"), - "address" => array("type" => "varchar(255)", "not null" => "1"), - "locality" => array("type" => "varchar(255)", "not null" => "1"), - "region" => array("type" => "varchar(255)", "not null" => "1"), - "postal-code" => array("type" => "varchar(32)", "not null" => "1"), - "country-name" => array("type" => "varchar(255)", "not null" => "1"), - "hometown" => array("type" => "varchar(255)", "not null" => "1"), - "gender" => array("type" => "varchar(32)", "not null" => "1"), - "marital" => array("type" => "varchar(255)", "not null" => "1"), + "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""), + "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""), + "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "with" => array("type" => "text", "not null" => "1"), "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), - "sexual" => array("type" => "varchar(255)", "not null" => "1"), - "politic" => array("type" => "varchar(255)", "not null" => "1"), - "religion" => array("type" => "varchar(255)", "not null" => "1"), + "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "pub_keywords" => array("type" => "text", "not null" => "1"), "prv_keywords" => array("type" => "text", "not null" => "1"), "likes" => array("type" => "text", "not null" => "1"), "dislikes" => array("type" => "text", "not null" => "1"), "about" => array("type" => "text", "not null" => "1"), - "summary" => array("type" => "varchar(255)", "not null" => "1"), + "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "music" => array("type" => "text", "not null" => "1"), "book" => array("type" => "text", "not null" => "1"), "tv" => array("type" => "text", "not null" => "1"), @@ -997,9 +1040,9 @@ function db_definition() { "work" => array("type" => "text", "not null" => "1"), "education" => array("type" => "text", "not null" => "1"), "contact" => array("type" => "text", "not null" => "1"), - "homepage" => array("type" => "varchar(255)", "not null" => "1"), - "photo" => array("type" => "varchar(255)", "not null" => "1"), - "thumb" => array("type" => "varchar(255)", "not null" => "1"), + "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), ), @@ -1011,11 +1054,11 @@ function db_definition() { $database["profile_check"] = array( "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "uid" => array("type" => "int(10) unsigned", "not null" => "1"), + "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), - "dfrn_id" => array("type" => "varchar(255)", "not null" => "1"), - "sec" => array("type" => "varchar(255)", "not null" => "1"), - "expire" => array("type" => "int(11)", "not null" => "1"), + "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"), ), "indexes" => array( "PRIMARY" => array("id"), @@ -1024,13 +1067,13 @@ function db_definition() { $database["push_subscriber"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "uid" => array("type" => "int(11)", "not null" => "1"), - "callback_url" => array("type" => "varchar(255)", "not null" => "1"), - "topic" => array("type" => "varchar(255)", "not null" => "1"), - "nickname" => array("type" => "varchar(255)", "not null" => "1"), - "push" => array("type" => "int(11)", "not null" => "1"), - "last_update" => array("type" => "datetime", "not null" => "1"), - "secret" => array("type" => "varchar(255)", "not null" => "1"), + "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "last_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), + "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), ), "indexes" => array( "PRIMARY" => array("id"), @@ -1039,10 +1082,10 @@ function db_definition() { $database["queue"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "cid" => array("type" => "int(11)", "not null" => "1"), - "network" => array("type" => "varchar(32)", "not null" => "1"), - "created" => array("type" => "datetime", "not null" => "1"), - "last" => array("type" => "datetime", "not null" => "1"), + "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""), + "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), + "last" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "content" => array("type" => "mediumtext", "not null" => "1"), "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), ), @@ -1058,11 +1101,11 @@ function db_definition() { $database["register"] = array( "fields" => array( "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "hash" => array("type" => "varchar(255)", "not null" => "1"), - "created" => array("type" => "datetime", "not null" => "1"), - "uid" => array("type" => "int(11) unsigned", "not null" => "1"), - "password" => array("type" => "varchar(255)", "not null" => "1"), - "language" => array("type" => "varchar(16)", "not null" => "1"), + "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), + "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"), + "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""), ), "indexes" => array( "PRIMARY" => array("id"), @@ -1071,8 +1114,8 @@ function db_definition() { $database["search"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "uid" => array("type" => "int(11)", "not null" => "1"), - "term" => array("type" => "varchar(255)", "not null" => "1"), + "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), ), "indexes" => array( "PRIMARY" => array("id"), @@ -1083,9 +1126,9 @@ function db_definition() { $database["session"] = array( "fields" => array( "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "sid" => array("type" => "varchar(255)", "not null" => "1"), + "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "data" => array("type" => "text", "not null" => "1"), - "expire" => array("type" => "int(10) unsigned", "not null" => "1"), + "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), ), "indexes" => array( "PRIMARY" => array("id"), @@ -1100,7 +1143,7 @@ function db_definition() { "retract_iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), "signed_text" => array("type" => "mediumtext", "not null" => "1"), "signature" => array("type" => "text", "not null" => "1"), - "signer" => array("type" => "varchar(255)", "not null" => "1"), + "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), ), "indexes" => array( "PRIMARY" => array("id"), @@ -1111,10 +1154,10 @@ function db_definition() { $database["spam"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "uid" => array("type" => "int(11)", "not null" => "1"), + "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"), - "term" => array("type" => "varchar(255)", "not null" => "1"), + "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), ), "indexes" => array( @@ -1128,11 +1171,11 @@ function db_definition() { $database["term"] = array( "fields" => array( "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "oid" => array("type" => "int(10) unsigned", "not null" => "1"), - "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1"), - "type" => array("type" => "tinyint(3) unsigned", "not null" => "1"), - "term" => array("type" => "varchar(255)", "not null" => "1"), - "url" => array("type" => "varchar(255)", "not null" => "1"), + "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), + "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"), + "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"), + "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), ), @@ -1169,7 +1212,7 @@ function db_definition() { "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), - "network" => array("type" => "varchar(32)", "not null" => "1"), + "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""), ), "indexes" => array( "PRIMARY" => array("iid"), @@ -1188,10 +1231,10 @@ function db_definition() { "fields" => array( "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"), "secret" => array("type" => "text", "not null" => "1"), - "client_id" => array("type" => "varchar(20)", "not null" => "1"), - "expires" => array("type" => "int(11)", "not null" => "1"), - "scope" => array("type" => "varchar(200)", "not null" => "1"), - "uid" => array("type" => "int(11)", "not null" => "1"), + "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""), + "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""), + "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), ), "indexes" => array( "PRIMARY" => array("id"), @@ -1200,10 +1243,10 @@ function db_definition() { $database["unique_contacts"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "url" => array("type" => "varchar(255)", "not null" => "1"), - "nick" => array("type" => "varchar(255)", "not null" => "1"), - "name" => array("type" => "varchar(255)", "not null" => "1"), - "avatar" => array("type" => "varchar(255)", "not null" => "1"), + "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), ), "indexes" => array( "PRIMARY" => array("id"), @@ -1213,19 +1256,19 @@ function db_definition() { $database["user"] = array( "fields" => array( "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "guid" => array("type" => "varchar(64)", "not null" => "1"), - "username" => array("type" => "varchar(255)", "not null" => "1"), - "password" => array("type" => "varchar(255)", "not null" => "1"), - "nickname" => array("type" => "varchar(255)", "not null" => "1"), - "email" => array("type" => "varchar(255)", "not null" => "1"), - "openid" => array("type" => "varchar(255)", "not null" => "1"), - "timezone" => array("type" => "varchar(128)", "not null" => "1"), + "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""), + "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""), "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"), "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), - "default-location" => array("type" => "varchar(255)", "not null" => "1"), + "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), - "theme" => array("type" => "varchar(255)", "not null" => "1"), + "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "pubkey" => array("type" => "text", "not null" => "1"), "prvkey" => array("type" => "text", "not null" => "1"), "spubkey" => array("type" => "text", "not null" => "1"), @@ -1240,14 +1283,14 @@ function db_definition() { "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"), "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"), "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), - "pwdreset" => array("type" => "varchar(255)", "not null" => "1"), + "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"), "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"), "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), - "service_class" => array("type" => "varchar(32)", "not null" => "1"), + "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""), "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "allow_cid" => array("type" => "mediumtext", "not null" => "1"), "allow_gid" => array("type" => "mediumtext", "not null" => "1"), @@ -1273,3 +1316,29 @@ function db_definition() { return($database); } + + +/* + * run from command line + */ +function dbstructure_run(&$argv, &$argc) { + global $a, $db; + + if(is_null($a)){ + $a = new App; + } + + if(is_null($db)) { + @include(".htconfig.php"); + require_once("include/dba.php"); + $db = new dba($db_host, $db_user, $db_pass, $db_data); + unset($db_host, $db_user, $db_pass, $db_data); + } + + update_structure(true, true); +} + +if (array_search(__file__,get_included_files())===0){ + dbstructure_run($argv,$argc); + killme(); +} diff --git a/include/diaspora.php b/include/diaspora.php index 8b85e7b955..99288b773c 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -2028,6 +2028,7 @@ function diaspora_retraction($importer,$xml) { dbesc(datetime_convert()), intval($r[0]['id']) ); + delete_thread($r[0]['id']); } } } @@ -2100,6 +2101,7 @@ function diaspora_signed_retraction($importer,$xml,$msg) { dbesc(datetime_convert()), intval($r[0]['id']) ); + delete_thread($r[0]['id']); // Now check if the retraction needs to be relayed by us // diff --git a/include/email.php b/include/email.php index dec8c93db7..0f24a42497 100644 --- a/include/email.php +++ b/include/email.php @@ -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"; diff --git a/include/enotify.php b/include/enotify.php index 970ece82eb..8b5002cb2a 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -1,10 +1,12 @@ config['sitename']; $site_admin = sprintf( t('%s Administrator'), $sitename); + $nickname = ""; $sender_name = $product; $hostname = $a->get_hostname(); @@ -26,15 +29,26 @@ function notification($params) { $hostname = substr($hostname,0,strpos($hostname,':')); $sender_email = t('noreply') . '@' . $hostname; - $additional_mail_header = ""; + $user = q("SELECT `nickname` FROM `user` WHERE `uid` = %d", intval($params['uid'])); + if ($user) + $nickname = $user[0]["nickname"]; + + // 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-Account: <".$nickname."@".$hostname.">\n"; $additional_mail_header .= "X-Friendica-Platform: ".FRIENDICA_PLATFORM."\n"; $additional_mail_header .= "X-Friendica-Version: ".FRIENDICA_VERSION."\n"; $additional_mail_header .= "List-ID: \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 +237,30 @@ function notification($params) { $tsitelink = sprintf( $sitelink, $siteurl ); $hsitelink = sprintf( $sitelink, '' . $sitename . ''); $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 +282,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, '' . $sitename . ''); + $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, '' . $sitename . ''); + $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, '' . $sitename . '

'); + $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; + } + + $subject .= " (".$nickname."@".$hostname.")"; + $h = array( 'params' => $params, 'subject' => $subject, @@ -274,114 +376,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 +508,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("
","\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"), "
\n",$body))),ENT_QUOTES,'UTF-8'); + $datarray = array(); $datarray['banner'] = $banner; $datarray['product'] = $product; @@ -448,14 +548,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","
\n",$datarray['preamble']), '$sitename' => $datarray['sitename'], '$siteurl' => $datarray['siteurl'], '$source_name' => $datarray['source_name'], @@ -494,9 +595,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 +609,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); - } -} ?> diff --git a/include/gprobe.php b/include/gprobe.php index 0cf32e95fe..36650eb9ae 100644 --- a/include/gprobe.php +++ b/include/gprobe.php @@ -10,7 +10,7 @@ function gprobe_run(&$argv, &$argc){ if(is_null($a)) { $a = new App; } - + if(is_null($db)) { @include(".htconfig.php"); require_once("include/dba.php"); @@ -37,6 +37,8 @@ function gprobe_run(&$argv, &$argc){ dbesc(normalise_link($url)) ); + logger("gprobe start for ".normalise_link($url), LOGGER_DEBUG); + if(! count($r)) { $arr = probe_url($url); @@ -55,7 +57,8 @@ function gprobe_run(&$argv, &$argc){ } if(count($r)) poco_load(0,0,$r[0]['id'], str_replace('/profile/','/poco/',$r[0]['url'])); - + + logger("gprobe end for ".normalise_link($url), LOGGER_DEBUG); return; } diff --git a/include/items.php b/include/items.php index 0e156beb27..22ae2f60a7 100644 --- a/include/items.php +++ b/include/items.php @@ -872,9 +872,18 @@ 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']); + $preview = ""; + + // Handle enclosures and treat them as preview picture + if (isset($attach)) + foreach ($attach AS $attachment) + if ($attachment->type == "image/jpeg") + $preview = $attachment->link; + + $res["body"] = $res["title"].add_page_info($res['plink'], false, $preview, ($contact['fetch_further_information'] == 2), $contact['ffi_keyword_blacklist']); $res["title"] = ""; $res["object-type"] = ACTIVITY_OBJ_BOOKMARK; + unset($res["attach"]); } elseif (isset($contact["network"]) AND ($contact["network"] == NETWORK_OSTATUS)) $res["body"] = add_page_info_to_body($res["body"]); elseif (isset($contact["network"]) AND ($contact["network"] == NETWORK_FEED) AND strstr($res['plink'], ".app.net/")) { @@ -888,12 +897,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 @@ -907,8 +912,14 @@ function add_page_info($url, $no_photos = false, $photo = "") { if ($no_photos AND ($data["type"] == "photo")) return(""); + // If the link contains BBCode stuff, make a short link out of this to avoid parsing problems + if (strpos($data["url"], '[') OR strpos($data["url"], ']')) { + require_once("include/network.php"); + $data["url"] = short_link($data["url"]); + } + 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 +931,51 @@ 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 = Cache::get("parse_url:".$url); + if (is_null($data)){ + $data = parseurl_getsiteinfo($url, true); + Cache::set("parse_url:".$url,serialize($data)); + } else + $data = unserialize($data); + + if ($photo != "") + $data["images"][0]["src"] = $photo; + + 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 +1184,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 +1472,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 +1998,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 +2637,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 +2648,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 +3788,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 +3907,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 +3921,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' ); + } } diff --git a/include/network.php b/include/network.php index 4c6af8e71b..6a37f4a549 100644 --- a/include/network.php +++ b/include/network.php @@ -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 variable -// of $st and an optional text of $message and terminates the current process. +// Outputs a basic dfrn XML status structure to STDOUT, with a variable +// of $st and an optional text 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"])) { @@ -1125,7 +1130,7 @@ function original_url($url, $depth=1, $fetchbody = false) { if (in_array($param, array("utm_source", "utm_medium", "utm_term", "utm_content", "utm_campaign", "wt_mc", "pk_campaign", "pk_kwd", "mc_cid", "mc_eid", "fb_action_ids", "fb_action_types", "fb_ref", - "awesm", + "awesm", "wtrid", "woo_campaign", "woo_source", "woo_medium", "woo_content", "woo_term"))) { $pair = $param."=".urlencode($value); @@ -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); diff --git a/include/oembed.php b/include/oembed.php index 2ecb11e1f5..0d7e5ee84f 100755 --- a/include/oembed.php +++ b/include/oembed.php @@ -78,6 +78,11 @@ function oembed_fetch_url($embedurl, $no_rich_type = false){ if (!is_object($j)) return false; + // Always embed the SSL version + if (isset($j->html)) + $j->html = str_replace(array("http://www.youtube.com/", "http://player.vimeo.com/"), + array("https://www.youtube.com/", "https://player.vimeo.com/"), $j->html); + $j->embedurl = $embedurl; // If fetching information doesn't work, then improve via internal functions diff --git a/include/onepoll.php b/include/onepoll.php index 9052937fdc..bb5b8905ab 100644 --- a/include/onepoll.php +++ b/include/onepoll.php @@ -15,7 +15,7 @@ function onepoll_run(&$argv, &$argc){ if(is_null($a)) { $a = new App; } - + if(is_null($db)) { @include(".htconfig.php"); require_once("include/dba.php"); @@ -57,28 +57,30 @@ function onepoll_run(&$argv, &$argc){ return; } - // Test $lockpath = get_lockpath(); if ($lockpath != '') { $pidfile = new pidfile($lockpath, 'onepoll'.$contact_id); - if($pidfile->is_already_running()) { + if ($pidfile->is_already_running()) { logger("onepoll: Already running for contact ".$contact_id); + if ($pidfile->running_time() > 9*60) { + $pidfile->kill(); + logger("killed stale process"); + } exit; } } - $d = datetime_convert(); // Only poll from those with suitable relationships, - // and which have a polling address and ignore Diaspora since + // and which have a polling address and ignore Diaspora since // we are unable to match those posts with a Diaspora GUID and prevent duplicates. - $contacts = q("SELECT `contact`.* FROM `contact` + $contacts = q("SELECT `contact`.* FROM `contact` WHERE ( `rel` = %d OR `rel` = %d ) AND `poll` != '' AND NOT `network` IN ( '%s', '%s', '%s' ) AND `contact`.`id` = %d - AND `self` = 0 AND `contact`.`blocked` = 0 AND `contact`.`readonly` = 0 + AND `self` = 0 AND `contact`.`blocked` = 0 AND `contact`.`readonly` = 0 AND `contact`.`archive` = 0 LIMIT 1", intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND), diff --git a/include/poller.php b/include/poller.php index e94ab8746f..0edda8170a 100644 --- a/include/poller.php +++ b/include/poller.php @@ -240,14 +240,14 @@ function poller_run(&$argv, &$argc){ // We should be getting everything via a hub. But just to be sure, let's check once a day. // (You can make this more or less frequent if desired by setting 'pushpoll_frequency' appropriately) // This also lets us update our subscription to the hub, and add or replace hubs in case it - // changed. We will only update hubs once a day, regardless of 'pushpoll_frequency'. + // changed. We will only update hubs once a day, regardless of 'pushpoll_frequency'. if($contact['subhub']) { $poll_interval = get_config('system','pushpoll_frequency'); $contact['priority'] = (($poll_interval !== false) ? intval($poll_interval) : 3); $hub_update = false; - + if((datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day")) || $force) $hub_update = true; } @@ -256,13 +256,13 @@ function poller_run(&$argv, &$argc){ /** * Based on $contact['priority'], should we poll this site now? Or later? - */ + */ switch ($contact['priority']) { case 5: if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 month")) $update = true; - break; + break; case 4: if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 week")) $update = true; @@ -285,7 +285,13 @@ function poller_run(&$argv, &$argc){ continue; } - proc_run('php','include/onepoll.php',$contact['id']); + // Don't run onepoll.php if the contact isn't pollable + // This check also is inside the onepoll.php - but this will reduce the load + if (in_array($contact["rel"], array(CONTACT_IS_SHARING, CONTACT_IS_FRIEND)) AND ($contact["poll"] != "") + AND !in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_FACEBOOK, NETWORK_PUMPIO, NETWORK_TWITTER, NETWORK_APPNET)) + AND !$contact["self"] AND !$contact["blocked"] AND !$contact["readonly"] AND !$contact["archive"]) + proc_run('php','include/onepoll.php',$contact['id']); + if($interval) @time_sleep_until(microtime(true) + (float) $interval); } diff --git a/include/tags.php b/include/tags.php index fbb9e6ff77..ea7eed84c3 100644 --- a/include/tags.php +++ b/include/tags.php @@ -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']); diff --git a/include/text.php b/include/text.php index 84195b0362..9fef4aebb5 100644 --- a/include/text.php +++ b/include/text.php @@ -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($kidentity = $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)); +} diff --git a/index.php b/index.php index 1b60071534..5dcb9a54a0 100644 --- a/index.php +++ b/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'] = "
{$_SESSION['sysmsg']}
\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)) diff --git a/js/acl.js b/js/acl.js index 9c55842fdc..487ffafc77 100644 --- a/js/acl.js +++ b/js/acl.js @@ -62,7 +62,7 @@ ACL.prototype.add_mention = function(id) { that.element.val( searchText + that.element.val() ); } else { if ( tinyMCE.activeEditor.getContent({format : 'raw'}).search(searchText) >= 0 ) return; - tinyMCE.activeEditor.dom.add(tinyMCE.activeEditor.getBody(), 'span', {}, searchText); + tinyMCE.activeEditor.dom.add(tinyMCE.activeEditor.getBody(), 'dummy', {}, searchText); } } diff --git a/js/acl.min.js b/js/acl.min.js deleted file mode 100644 index b3ad459e96..0000000000 --- a/js/acl.min.js +++ /dev/null @@ -1 +0,0 @@ -function ACL(backend_url,preset){that=this;that.url=backend_url;that.kp_timer=null;if(preset==undefined)preset=[];that.allow_cid=preset[0]||[];that.allow_gid=preset[1]||[];that.deny_cid=preset[2]||[];that.deny_gid=preset[3]||[];that.group_uids=[];that.nw=4;that.list_content=$("#acl-list-content");that.item_tpl=unescape($(".acl-list-item[rel=acl-template]").html());that.showall=$("#acl-showall");if(preset.length==0)that.showall.addClass("selected");that.showall.click(that.on_showall);$(".acl-button-show").live("click",that.on_button_show);$(".acl-button-hide").live("click",that.on_button_hide);$("#acl-search").keypress(that.on_search);$("#acl-wrapper").parents("form").submit(that.on_submit);that.get(0,100)}ACL.prototype.on_submit=function(){aclfileds=$("#acl-fields").html("");$(that.allow_gid).each(function(i,v){aclfileds.append("")});$(that.allow_cid).each(function(i,v){aclfileds.append("")});$(that.deny_gid).each(function(i,v){aclfileds.append("")});$(that.deny_cid).each(function(i,v){aclfileds.append("")})};ACL.prototype.search=function(){var srcstr=$("#acl-search").val();that.list_content.html("");that.get(0,100,srcstr)};ACL.prototype.on_search=function(event){if(that.kp_timer)clearTimeout(that.kp_timer);that.kp_timer=setTimeout(that.search,1e3)};ACL.prototype.on_showall=function(event){event.preventDefault();event.stopPropagation();if(that.showall.hasClass("selected")){return false}that.showall.addClass("selected");that.allow_cid=[];that.allow_gid=[];that.deny_cid=[];that.deny_gid=[];that.update_view();return false};ACL.prototype.on_button_show=function(event){event.preventDefault();event.stopImmediatePropagation();event.stopPropagation();that.set_allow($(this).parent().attr("id"));return false};ACL.prototype.on_button_hide=function(event){event.preventDefault();event.stopImmediatePropagation();event.stopPropagation();that.set_deny($(this).parent().attr("id"));return false};ACL.prototype.set_allow=function(itemid){type=itemid[0];id=parseInt(itemid.substr(1));switch(type){case"g":if(that.allow_gid.indexOf(id)<0){that.allow_gid.push(id)}else{that.allow_gid.remove(id)}if(that.deny_gid.indexOf(id)>=0)that.deny_gid.remove(id);break;case"c":if(that.allow_cid.indexOf(id)<0){that.allow_cid.push(id)}else{that.allow_cid.remove(id)}if(that.deny_cid.indexOf(id)>=0)that.deny_cid.remove(id);break}that.update_view()};ACL.prototype.set_deny=function(itemid){type=itemid[0];id=parseInt(itemid.substr(1));switch(type){case"g":if(that.deny_gid.indexOf(id)<0){that.deny_gid.push(id)}else{that.deny_gid.remove(id)}if(that.allow_gid.indexOf(id)>=0)that.allow_gid.remove(id);break;case"c":if(that.deny_cid.indexOf(id)<0){that.deny_cid.push(id)}else{that.deny_cid.remove(id)}if(that.allow_cid.indexOf(id)>=0)that.allow_cid.remove(id);break}that.update_view()};ACL.prototype.update_view=function(){if(that.allow_gid.length==0&&that.allow_cid.length==0&&that.deny_gid.length==0&&that.deny_cid.length==0){that.showall.addClass("selected");$("#jot-perms-icon").removeClass("lock").addClass("unlock");$("#jot-public").show();$(".profile-jot-net input").attr("disabled",false);if(typeof editor!="undefined"&&editor!=false){$("#profile-jot-desc").html(ispublic)}}else{that.showall.removeClass("selected");$("#jot-perms-icon").removeClass("unlock").addClass("lock");$("#jot-public").hide();$(".profile-jot-net input").attr("disabled","disabled");$("#profile-jot-desc").html(" ")}$("#acl-list-content .acl-list-item").each(function(){$(this).removeClass("groupshow grouphide")});$("#acl-list-content .acl-list-item").each(function(){itemid=$(this).attr("id");type=itemid[0];id=parseInt(itemid.substr(1));btshow=$(this).children(".acl-button-show").removeClass("selected");bthide=$(this).children(".acl-button-hide").removeClass("selected");switch(type){case"g":var uclass="";if(that.allow_gid.indexOf(id)>=0){btshow.addClass("selected");bthide.removeClass("selected");uclass="groupshow"}if(that.deny_gid.indexOf(id)>=0){btshow.removeClass("selected");bthide.addClass("selected");uclass="grouphide"}$(that.group_uids[id]).each(function(i,v){if(uclass=="grouphide")$("#c"+v).removeClass("groupshow");if(uclass!=""){var cls=$("#c"+v).attr("class");if(cls==undefined)return true;var hiding=cls.indexOf("grouphide");if(hiding==-1)$("#c"+v).addClass(uclass)}});break;case"c":if(that.allow_cid.indexOf(id)>=0){btshow.addClass("selected");bthide.removeClass("selected")}if(that.deny_cid.indexOf(id)>=0){btshow.removeClass("selected");bthide.addClass("selected")}}})};ACL.prototype.get=function(start,count,search){var postdata={start:start,count:count,search:search};$.ajax({type:"POST",url:that.url,data:postdata,dataType:"json",success:that.populate})};ACL.prototype.populate=function(data){var height=Math.ceil(data.tot/that.nw)*42;that.list_content.height(height);$(data.items).each(function(){html="
"+that.item_tpl+"
";html=html.format(this.photo,this.name,this.type,this.id,"",this.network,this.link);if(this.uids!=undefined)that.group_uids[this.id]=this.uids;that.list_content.append(html)});$(".acl-list-item img[data-src]",that.list_content).each(function(i,el){$(el).attr("src",$(el).data("src"))});that.update_view()}; \ No newline at end of file diff --git a/js/ajaxupload.min.js b/js/ajaxupload.min.js deleted file mode 100644 index 960bf3b87a..0000000000 --- a/js/ajaxupload.min.js +++ /dev/null @@ -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('', - error : '

The requested content cannot be loaded.
Please try again later.

', - closeBtn : '', - next : '', - prev : '' - }, - - // Properties for each animation type - // Opening fancyBox - openEffect : 'fade', // 'elastic', 'fade' or 'none' - openSpeed : 250, - openEasing : 'swing', - openOpacity : true, - openMethod : 'zoomIn', - - // Closing fancyBox - closeEffect : 'fade', // 'elastic', 'fade' or 'none' - closeSpeed : 250, - closeEasing : 'swing', - closeOpacity : true, - closeMethod : 'zoomOut', - - // Changing next gallery item - nextEffect : 'elastic', // 'elastic', 'fade' or 'none' - nextSpeed : 250, - nextEasing : 'swing', - nextMethod : 'changeIn', - - // Changing previous gallery item - prevEffect : 'elastic', // 'elastic', 'fade' or 'none' - prevSpeed : 250, - prevEasing : 'swing', - prevMethod : 'changeOut', - - // Enable default helpers - helpers : { - overlay : true, - title : true - }, - - // Callbacks - onCancel : $.noop, // If canceling - beforeLoad : $.noop, // Before loading - afterLoad : $.noop, // After loading - beforeShow : $.noop, // Before changing in current item - afterShow : $.noop, // After opening - beforeChange : $.noop, // Before changing gallery item - beforeClose : $.noop, // Before closing - afterClose : $.noop // After closing - }, - - //Current state - group : {}, // Selected group - opts : {}, // Group options - previous : null, // Previous element - coming : null, // Element being loaded - current : null, // Currently loaded element - isActive : false, // Is activated - isOpen : false, // Is currently open - isOpened : false, // Have been fully opened at least once - - wrap : null, - skin : null, - outer : null, - inner : null, - - player : { - timer : null, - isActive : false - }, - - // Loaders - ajaxLoad : null, - imgPreload : null, - - // Some collections - transitions : {}, - helpers : {}, - - /* - * Static methods - */ - - open: function (group, opts) { - if (!group) { - return; - } - - if (!$.isPlainObject(opts)) { - opts = {}; - } - - // Close if already active - if (false === F.close(true)) { - return; - } - - // Normalize group - if (!$.isArray(group)) { - group = isQuery(group) ? $(group).get() : [group]; - } - - // Recheck if the type of each element is `object` and set content type (image, ajax, etc) - $.each(group, function(i, element) { - var obj = {}, - href, - title, - content, - type, - rez, - hrefParts, - selector; - - if ($.type(element) === "object") { - // Check if is DOM element - if (element.nodeType) { - element = $(element); - } - - if (isQuery(element)) { - obj = { - href : element.data('fancybox-href') || element.attr('href'), - title : element.data('fancybox-title') || element.attr('title'), - isDom : true, - element : element - }; - - if ($.metadata) { - $.extend(true, obj, element.metadata()); - } - - } else { - obj = element; - } - } - - href = opts.href || obj.href || (isString(element) ? element : null); - title = opts.title !== undefined ? opts.title : obj.title || ''; - - content = opts.content || obj.content; - type = content ? 'html' : (opts.type || obj.type); - - if (!type && obj.isDom) { - type = element.data('fancybox-type'); - - if (!type) { - rez = element.prop('class').match(/fancybox\.(\w+)/); - type = rez ? rez[1] : null; - } - } - - if (isString(href)) { - // Try to guess the content type - if (!type) { - if (F.isImage(href)) { - type = 'image'; - - } else if (F.isSWF(href)) { - type = 'swf'; - - } else if (href.charAt(0) === '#') { - type = 'inline'; - - } else if (isString(element)) { - type = 'html'; - content = element; - } - } - - // Split url into two pieces with source url and content selector, e.g, - // "/mypage.html #my_id" will load "/mypage.html" and display element having id "my_id" - if (type === 'ajax') { - hrefParts = href.split(/\s+/, 2); - href = hrefParts.shift(); - selector = hrefParts.shift(); - } - } - - if (!content) { - if (type === 'inline') { - if (href) { - content = $( isString(href) ? href.replace(/.*(?=#[^\s]+$)/, '') : href ); //strip for ie7 - - } else if (obj.isDom) { - content = element; - } - - } else if (type === 'html') { - content = href; - - } else if (!type && !href && obj.isDom) { - type = 'inline'; - content = element; - } - } - - $.extend(obj, { - href : href, - type : type, - content : content, - title : title, - selector : selector - }); - - group[ i ] = obj; - }); - - // Extend the defaults - F.opts = $.extend(true, {}, F.defaults, opts); - - // All options are merged recursive except keys - if (opts.keys !== undefined) { - F.opts.keys = opts.keys ? $.extend({}, F.defaults.keys, opts.keys) : false; - } - - F.group = group; - - return F._start(F.opts.index); - }, - - // Cancel image loading or abort ajax request - cancel: function () { - var coming = F.coming; - - if (!coming || false === F.trigger('onCancel')) { - return; - } - - F.hideLoading(); - - if (F.ajaxLoad) { - F.ajaxLoad.abort(); - } - - F.ajaxLoad = null; - - if (F.imgPreload) { - F.imgPreload.onload = F.imgPreload.onerror = null; - } - - if (coming.wrap) { - coming.wrap.stop(true, true).trigger('onReset').remove(); - } - - F.coming = null; - - // If the first item has been canceled, then clear everything - if (!F.current) { - F._afterZoomOut( coming ); - } - }, - - // Start closing animation if is open; remove immediately if opening/closing - close: function (event) { - F.cancel(); - - if (false === F.trigger('beforeClose')) { - return; - } - - F.unbindEvents(); - - if (!F.isActive) { - return; - } - - if (!F.isOpen || event === true) { - $('.fancybox-wrap').stop(true).trigger('onReset').remove(); - - F._afterZoomOut(); - - } else { - F.isOpen = F.isOpened = false; - F.isClosing = true; - - $('.fancybox-item, .fancybox-nav').remove(); - - F.wrap.stop(true, true).removeClass('fancybox-opened'); - - F.transitions[ F.current.closeMethod ](); - } - }, - - // Manage slideshow: - // $.fancybox.play(); - toggle slideshow - // $.fancybox.play( true ); - start - // $.fancybox.play( false ); - stop - play: function ( action ) { - var clear = function () { - clearTimeout(F.player.timer); - }, - set = function () { - clear(); - - if (F.current && F.player.isActive) { - F.player.timer = setTimeout(F.next, F.current.playSpeed); - } - }, - stop = function () { - clear(); - - D.unbind('.player'); - - F.player.isActive = false; - - F.trigger('onPlayEnd'); - }, - start = function () { - if (F.current && (F.current.loop || F.current.index < F.group.length - 1)) { - F.player.isActive = true; - - D.bind({ - 'onCancel.player beforeClose.player' : stop, - 'onUpdate.player' : set, - 'beforeLoad.player' : clear - }); - - set(); - - F.trigger('onPlayStart'); - } - }; - - if (action === true || (!F.player.isActive && action !== false)) { - start(); - } else { - stop(); - } - }, - - // Navigate to next gallery item - next: function ( direction ) { - var current = F.current; - - if (current) { - if (!isString(direction)) { - direction = current.direction.next; - } - - F.jumpto(current.index + 1, direction, 'next'); - } - }, - - // Navigate to previous gallery item - prev: function ( direction ) { - var current = F.current; - - if (current) { - if (!isString(direction)) { - direction = current.direction.prev; - } - - F.jumpto(current.index - 1, direction, 'prev'); - } - }, - - // Navigate to gallery item by index - jumpto: function ( index, direction, router ) { - var current = F.current; - - if (!current) { - return; - } - - index = getScalar(index); - - F.direction = direction || current.direction[ (index >= current.index ? 'next' : 'prev') ]; - F.router = router || 'jumpto'; - - if (current.loop) { - if (index < 0) { - index = current.group.length + (index % current.group.length); - } - - index = index % current.group.length; - } - - if (current.group[ index ] !== undefined) { - F.cancel(); - - F._start(index); - } - }, - - // Center inside viewport and toggle position type to fixed or absolute if needed - reposition: function (e, onlyAbsolute) { - var current = F.current, - wrap = current ? current.wrap : null, - pos; - - if (wrap) { - pos = F._getPosition(onlyAbsolute); - - if (e && e.type === 'scroll') { - delete pos.position; - - wrap.stop(true, true).animate(pos, 200); - - } else { - wrap.css(pos); - - current.pos = $.extend({}, current.dim, pos); - } - } - }, - - update: function (e) { - var type = (e && e.type), - anyway = !type || type === 'orientationchange'; - - if (anyway) { - clearTimeout(didUpdate); - - didUpdate = null; - } - - if (!F.isOpen || didUpdate) { - return; - } - - didUpdate = setTimeout(function() { - var current = F.current; - - if (!current || F.isClosing) { - return; - } - - F.wrap.removeClass('fancybox-tmp'); - - if (anyway || type === 'load' || (type === 'resize' && current.autoResize)) { - F._setDimension(); - } - - if (!(type === 'scroll' && current.canShrink)) { - F.reposition(e); - } - - F.trigger('onUpdate'); - - didUpdate = null; - - }, (anyway && !isTouch ? 0 : 300)); - }, - - // Shrink content to fit inside viewport or restore if resized - toggle: function ( action ) { - if (F.isOpen) { - F.current.fitToView = $.type(action) === "boolean" ? action : !F.current.fitToView; - - // Help browser to restore document dimensions - if (isTouch) { - F.wrap.removeAttr('style').addClass('fancybox-tmp'); - - F.trigger('onUpdate'); - } - - F.update(); - } - }, - - hideLoading: function () { - D.unbind('.loading'); - - $('#fancybox-loading').remove(); - }, - - showLoading: function () { - var el, viewport; - - F.hideLoading(); - - el = $('
').click(F.cancel).appendTo('body'); - - // If user will press the escape-button, the request will be canceled - D.bind('keydown.loading', function(e) { - if ((e.which || e.keyCode) === 27) { - e.preventDefault(); - - F.cancel(); - } - }); - - if (!F.defaults.fixed) { - viewport = F.getViewport(); - - el.css({ - position : 'absolute', - top : (viewport.h * 0.5) + viewport.y, - left : (viewport.w * 0.5) + viewport.x - }); - } - }, - - getViewport: function () { - var locked = (F.current && F.current.locked) || false, - rez = { - x: W.scrollLeft(), - y: W.scrollTop() - }; - - if (locked) { - rez.w = locked[0].clientWidth; - rez.h = locked[0].clientHeight; - - } else { - // See http://bugs.jquery.com/ticket/6724 - rez.w = isTouch && window.innerWidth ? window.innerWidth : W.width(); - rez.h = isTouch && window.innerHeight ? window.innerHeight : W.height(); - } - - return rez; - }, - - // Unbind the keyboard / clicking actions - unbindEvents: function () { - if (F.wrap && isQuery(F.wrap)) { - F.wrap.unbind('.fb'); - } - - D.unbind('.fb'); - W.unbind('.fb'); - }, - - bindEvents: function () { - var current = F.current, - keys; - - if (!current) { - return; - } - - // Changing document height on iOS devices triggers a 'resize' event, - // that can change document height... repeating infinitely - W.bind('orientationchange.fb' + (isTouch ? '' : ' resize.fb') + (current.autoCenter && !current.locked ? ' scroll.fb' : ''), F.update); - - keys = current.keys; - - if (keys) { - D.bind('keydown.fb', function (e) { - var code = e.which || e.keyCode, - target = e.target || e.srcElement; - - // Skip esc key if loading, because showLoading will cancel preloading - if (code === 27 && F.coming) { - return false; - } - - // Ignore key combinations and key events within form elements - if (!e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey && !(target && (target.type || $(target).is('[contenteditable]')))) { - $.each(keys, function(i, val) { - if (current.group.length > 1 && val[ code ] !== undefined) { - F[ i ]( val[ code ] ); - - e.preventDefault(); - return false; - } - - if ($.inArray(code, val) > -1) { - F[ i ] (); - - e.preventDefault(); - return false; - } - }); - } - }); - } - - if ($.fn.mousewheel && current.mouseWheel) { - F.wrap.bind('mousewheel.fb', function (e, delta, deltaX, deltaY) { - var target = e.target || null, - parent = $(target), - canScroll = false; - - while (parent.length) { - if (canScroll || parent.is('.fancybox-skin') || parent.is('.fancybox-wrap')) { - break; - } - - canScroll = isScrollable( parent[0] ); - parent = $(parent).parent(); - } - - if (delta !== 0 && !canScroll) { - if (F.group.length > 1 && !current.canShrink) { - if (deltaY > 0 || deltaX > 0) { - F.prev( deltaY > 0 ? 'down' : 'left' ); - - } else if (deltaY < 0 || deltaX < 0) { - F.next( deltaY < 0 ? 'up' : 'right' ); - } - - e.preventDefault(); - } - } - }); - } - }, - - trigger: function (event, o) { - var ret, obj = o || F.coming || F.current; - - if (!obj) { - return; - } - - if ($.isFunction( obj[event] )) { - ret = obj[event].apply(obj, Array.prototype.slice.call(arguments, 1)); - } - - if (ret === false) { - return false; - } - - if (obj.helpers) { - $.each(obj.helpers, function (helper, opts) { - if (opts && F.helpers[helper] && $.isFunction(F.helpers[helper][event])) { - opts = $.extend(true, {}, F.helpers[helper].defaults, opts); - - F.helpers[helper][event](opts, obj); - } - }); - } - - D.trigger(event); - }, - - isImage: function (str) { - return isString(str) && str.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp)((\?|#).*)?$)/i); - }, - - isSWF: function (str) { - return isString(str) && str.match(/\.(swf)((\?|#).*)?$/i); - }, - - _start: function (index) { - var coming = {}, - obj, - href, - type, - margin, - padding; - - index = getScalar( index ); - obj = F.group[ index ] || null; - - if (!obj) { - return false; - } - - coming = $.extend(true, {}, F.opts, obj); - - // Convert margin and padding properties to array - top, right, bottom, left - margin = coming.margin; - padding = coming.padding; - - if ($.type(margin) === 'number') { - coming.margin = [margin, margin, margin, margin]; - } - - if ($.type(padding) === 'number') { - coming.padding = [padding, padding, padding, padding]; - } - - // 'modal' propery is just a shortcut - if (coming.modal) { - $.extend(true, coming, { - closeBtn : false, - closeClick : false, - nextClick : false, - arrows : false, - mouseWheel : false, - keys : null, - helpers: { - overlay : { - closeClick : false - } - } - }); - } - - // 'autoSize' property is a shortcut, too - if (coming.autoSize) { - coming.autoWidth = coming.autoHeight = true; - } - - if (coming.width === 'auto') { - coming.autoWidth = true; - } - - if (coming.height === 'auto') { - coming.autoHeight = true; - } - - /* - * Add reference to the group, so it`s possible to access from callbacks, example: - * afterLoad : function() { - * this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : ''); - * } - */ - - coming.group = F.group; - coming.index = index; - - // Give a chance for callback or helpers to update coming item (type, title, etc) - F.coming = coming; - - if (false === F.trigger('beforeLoad')) { - F.coming = null; - - return; - } - - type = coming.type; - href = coming.href; - - if (!type) { - F.coming = null; - - //If we can not determine content type then drop silently or display next/prev item if looping through gallery - if (F.current && F.router && F.router !== 'jumpto') { - F.current.index = index; - - return F[ F.router ]( F.direction ); - } - - return false; - } - - F.isActive = true; - - if (type === 'image' || type === 'swf') { - coming.autoHeight = coming.autoWidth = false; - coming.scrolling = 'visible'; - } - - if (type === 'image') { - coming.aspectRatio = true; - } - - if (type === 'iframe' && isTouch) { - coming.scrolling = 'scroll'; - } - - // Build the neccessary markup - coming.wrap = $(coming.tpl.wrap).addClass('fancybox-' + (isTouch ? 'mobile' : 'desktop') + ' fancybox-type-' + type + ' fancybox-tmp ' + coming.wrapCSS).appendTo( coming.parent || 'body' ); - - $.extend(coming, { - skin : $('.fancybox-skin', coming.wrap), - outer : $('.fancybox-outer', coming.wrap), - inner : $('.fancybox-inner', coming.wrap) - }); - - $.each(["Top", "Right", "Bottom", "Left"], function(i, v) { - coming.skin.css('padding' + v, getValue(coming.padding[ i ])); - }); - - F.trigger('onReady'); - - // Check before try to load; 'inline' and 'html' types need content, others - href - if (type === 'inline' || type === 'html') { - if (!coming.content || !coming.content.length) { - return F._error( 'content' ); - } - - } else if (!href) { - return F._error( 'href' ); - } - - if (type === 'image') { - F._loadImage(); - - } else if (type === 'ajax') { - F._loadAjax(); - - } else if (type === 'iframe') { - F._loadIframe(); - - } else { - F._afterLoad(); - } - }, - - _error: function ( type ) { - $.extend(F.coming, { - type : 'html', - autoWidth : true, - autoHeight : true, - minWidth : 0, - minHeight : 0, - scrolling : 'no', - hasError : type, - content : F.coming.tpl.error - }); - - F._afterLoad(); - }, - - _loadImage: function () { - // Reset preload image so it is later possible to check "complete" property - var img = F.imgPreload = new Image(); - - img.onload = function () { - this.onload = this.onerror = null; - - F.coming.width = this.width; - F.coming.height = this.height; - - F._afterLoad(); - }; - - img.onerror = function () { - this.onload = this.onerror = null; - - F._error( 'image' ); - }; - - img.src = F.coming.href; - - if (img.complete !== true) { - F.showLoading(); - } - }, - - _loadAjax: function () { - var coming = F.coming; - - F.showLoading(); - - F.ajaxLoad = $.ajax($.extend({}, coming.ajax, { - url: coming.href, - error: function (jqXHR, textStatus) { - if (F.coming && textStatus !== 'abort') { - F._error( 'ajax', jqXHR ); - - } else { - F.hideLoading(); - } - }, - success: function (data, textStatus) { - if (textStatus === 'success') { - coming.content = data; - - F._afterLoad(); - } - } - })); - }, - - _loadIframe: function() { - var coming = F.coming, - iframe = $(coming.tpl.iframe.replace(/\{rnd\}/g, new Date().getTime())) - .attr('scrolling', isTouch ? 'auto' : coming.iframe.scrolling) - .attr('src', coming.href); - - // This helps IE - $(coming.wrap).bind('onReset', function () { - try { - $(this).find('iframe').hide().attr('src', '//about:blank').end().empty(); - } catch (e) {} - }); - - if (coming.iframe.preload) { - F.showLoading(); - - iframe.one('load', function() { - $(this).data('ready', 1); - - // iOS will lose scrolling if we resize - if (!isTouch) { - $(this).bind('load.fb', F.update); - } - - // Without this trick: - // - iframe won't scroll on iOS devices - // - IE7 sometimes displays empty iframe - $(this).parents('.fancybox-wrap').width('100%').removeClass('fancybox-tmp').show(); - - F._afterLoad(); - }); - } - - coming.content = iframe.appendTo( coming.inner ); - - if (!coming.iframe.preload) { - F._afterLoad(); - } - }, - - _preloadImages: function() { - var group = F.group, - current = F.current, - len = group.length, - cnt = current.preload ? Math.min(current.preload, len - 1) : 0, - item, - i; - - for (i = 1; i <= cnt; i += 1) { - item = group[ (current.index + i ) % len ]; - - if (item.type === 'image' && item.href) { - new Image().src = item.href; - } - } - }, - - _afterLoad: function () { - var coming = F.coming, - previous = F.current, - placeholder = 'fancybox-placeholder', - current, - content, - type, - scrolling, - href, - embed; - - F.hideLoading(); - - if (!coming || F.isActive === false) { - return; - } - - if (false === F.trigger('afterLoad', coming, previous)) { - coming.wrap.stop(true).trigger('onReset').remove(); - - F.coming = null; - - return; - } - - if (previous) { - F.trigger('beforeChange', previous); - - previous.wrap.stop(true).removeClass('fancybox-opened') - .find('.fancybox-item, .fancybox-nav') - .remove(); - } - - F.unbindEvents(); - - current = coming; - content = coming.content; - type = coming.type; - scrolling = coming.scrolling; - - $.extend(F, { - wrap : current.wrap, - skin : current.skin, - outer : current.outer, - inner : current.inner, - current : current, - previous : previous - }); - - href = current.href; - - switch (type) { - case 'inline': - case 'ajax': - case 'html': - if (current.selector) { - content = $('
').html(content).find(current.selector); - - } else if (isQuery(content)) { - if (!content.data(placeholder)) { - content.data(placeholder, $('
').insertAfter( content ).hide() ); - } - - content = content.show().detach(); - - current.wrap.bind('onReset', function () { - if ($(this).find(content).length) { - content.hide().replaceAll( content.data(placeholder) ).data(placeholder, false); - } - }); - } - break; - - case 'image': - content = current.tpl.image.replace('{href}', href); - break; - - case 'swf': - content = ''; - embed = ''; - - $.each(current.swf, function(name, val) { - content += ''; - embed += ' ' + name + '="' + val + '"'; - }); - - content += ''; - break; - } - - if (!(isQuery(content) && content.parent().is(current.inner))) { - current.inner.append( content ); - } - - // Give a chance for helpers or callbacks to update elements - F.trigger('beforeShow'); - - // Set scrolling before calculating dimensions - current.inner.css('overflow', scrolling === 'yes' ? 'scroll' : (scrolling === 'no' ? 'hidden' : scrolling)); - - // Set initial dimensions and start position - F._setDimension(); - - F.reposition(); - - F.isOpen = false; - F.coming = null; - - F.bindEvents(); - - if (!F.isOpened) { - $('.fancybox-wrap').not( current.wrap ).stop(true).trigger('onReset').remove(); - - } else if (previous.prevMethod) { - F.transitions[ previous.prevMethod ](); - } - - F.transitions[ F.isOpened ? current.nextMethod : current.openMethod ](); - - F._preloadImages(); - }, - - _setDimension: function () { - var viewport = F.getViewport(), - steps = 0, - canShrink = false, - canExpand = false, - wrap = F.wrap, - skin = F.skin, - inner = F.inner, - current = F.current, - width = current.width, - height = current.height, - minWidth = current.minWidth, - minHeight = current.minHeight, - maxWidth = current.maxWidth, - maxHeight = current.maxHeight, - scrolling = current.scrolling, - scrollOut = current.scrollOutside ? current.scrollbarWidth : 0, - margin = current.margin, - wMargin = getScalar(margin[1] + margin[3]), - hMargin = getScalar(margin[0] + margin[2]), - wPadding, - hPadding, - wSpace, - hSpace, - origWidth, - origHeight, - origMaxWidth, - origMaxHeight, - ratio, - width_, - height_, - maxWidth_, - maxHeight_, - iframe, - body; - - // Reset dimensions so we could re-check actual size - wrap.add(skin).add(inner).width('auto').height('auto').removeClass('fancybox-tmp'); - - wPadding = getScalar(skin.outerWidth(true) - skin.width()); - hPadding = getScalar(skin.outerHeight(true) - skin.height()); - - // Any space between content and viewport (margin, padding, border, title) - wSpace = wMargin + wPadding; - hSpace = hMargin + hPadding; - - origWidth = isPercentage(width) ? (viewport.w - wSpace) * getScalar(width) / 100 : width; - origHeight = isPercentage(height) ? (viewport.h - hSpace) * getScalar(height) / 100 : height; - - if (current.type === 'iframe') { - iframe = current.content; - - if (current.autoHeight && iframe.data('ready') === 1) { - try { - if (iframe[0].contentWindow.document.location) { - inner.width( origWidth ).height(9999); - - body = iframe.contents().find('body'); - - if (scrollOut) { - body.css('overflow-x', 'hidden'); - } - - origHeight = body.height(); - } - - } catch (e) {} - } - - } else if (current.autoWidth || current.autoHeight) { - inner.addClass( 'fancybox-tmp' ); - - // Set width or height in case we need to calculate only one dimension - if (!current.autoWidth) { - inner.width( origWidth ); - } - - if (!current.autoHeight) { - inner.height( origHeight ); - } - - if (current.autoWidth) { - origWidth = inner.width(); - } - - if (current.autoHeight) { - origHeight = inner.height(); - } - - inner.removeClass( 'fancybox-tmp' ); - } - - width = getScalar( origWidth ); - height = getScalar( origHeight ); - - ratio = origWidth / origHeight; - - // Calculations for the content - minWidth = getScalar(isPercentage(minWidth) ? getScalar(minWidth, 'w') - wSpace : minWidth); - maxWidth = getScalar(isPercentage(maxWidth) ? getScalar(maxWidth, 'w') - wSpace : maxWidth); - - minHeight = getScalar(isPercentage(minHeight) ? getScalar(minHeight, 'h') - hSpace : minHeight); - maxHeight = getScalar(isPercentage(maxHeight) ? getScalar(maxHeight, 'h') - hSpace : maxHeight); - - // These will be used to determine if wrap can fit in the viewport - origMaxWidth = maxWidth; - origMaxHeight = maxHeight; - - if (current.fitToView) { - maxWidth = Math.min(viewport.w - wSpace, maxWidth); - maxHeight = Math.min(viewport.h - hSpace, maxHeight); - } - - maxWidth_ = viewport.w - wMargin; - maxHeight_ = viewport.h - hMargin; - - if (current.aspectRatio) { - if (width > maxWidth) { - width = maxWidth; - height = getScalar(width / ratio); - } - - if (height > maxHeight) { - height = maxHeight; - width = getScalar(height * ratio); - } - - if (width < minWidth) { - width = minWidth; - height = getScalar(width / ratio); - } - - if (height < minHeight) { - height = minHeight; - width = getScalar(height * ratio); - } - - } else { - width = Math.max(minWidth, Math.min(width, maxWidth)); - - if (current.autoHeight && current.type !== 'iframe') { - inner.width( width ); - - height = inner.height(); - } - - height = Math.max(minHeight, Math.min(height, maxHeight)); - } - - // Try to fit inside viewport (including the title) - if (current.fitToView) { - inner.width( width ).height( height ); - - wrap.width( width + wPadding ); - - // Real wrap dimensions - width_ = wrap.width(); - height_ = wrap.height(); - - if (current.aspectRatio) { - while ((width_ > maxWidth_ || height_ > maxHeight_) && width > minWidth && height > minHeight) { - if (steps++ > 19) { - break; - } - - height = Math.max(minHeight, Math.min(maxHeight, height - 10)); - width = getScalar(height * ratio); - - if (width < minWidth) { - width = minWidth; - height = getScalar(width / ratio); - } - - if (width > maxWidth) { - width = maxWidth; - height = getScalar(width / ratio); - } - - inner.width( width ).height( height ); - - wrap.width( width + wPadding ); - - width_ = wrap.width(); - height_ = wrap.height(); - } - - } else { - width = Math.max(minWidth, Math.min(width, width - (width_ - maxWidth_))); - height = Math.max(minHeight, Math.min(height, height - (height_ - maxHeight_))); - } - } - - if (scrollOut && scrolling === 'auto' && height < origHeight && (width + wPadding + scrollOut) < maxWidth_) { - width += scrollOut; - } - - inner.width( width ).height( height ); - - wrap.width( width + wPadding ); - - width_ = wrap.width(); - height_ = wrap.height(); - - canShrink = (width_ > maxWidth_ || height_ > maxHeight_) && width > minWidth && height > minHeight; - canExpand = current.aspectRatio ? (width < origMaxWidth && height < origMaxHeight && width < origWidth && height < origHeight) : ((width < origMaxWidth || height < origMaxHeight) && (width < origWidth || height < origHeight)); - - $.extend(current, { - dim : { - width : getValue( width_ ), - height : getValue( height_ ) - }, - origWidth : origWidth, - origHeight : origHeight, - canShrink : canShrink, - canExpand : canExpand, - wPadding : wPadding, - hPadding : hPadding, - wrapSpace : height_ - skin.outerHeight(true), - skinSpace : skin.height() - height - }); - - if (!iframe && current.autoHeight && height > minHeight && height < maxHeight && !canExpand) { - inner.height('auto'); - } - }, - - _getPosition: function (onlyAbsolute) { - var current = F.current, - viewport = F.getViewport(), - margin = current.margin, - width = F.wrap.width() + margin[1] + margin[3], - height = F.wrap.height() + margin[0] + margin[2], - rez = { - position: 'absolute', - top : margin[0], - left : margin[3] - }; - - if (current.autoCenter && current.fixed && !onlyAbsolute && height <= viewport.h && width <= viewport.w) { - rez.position = 'fixed'; - - } else if (!current.locked) { - rez.top += viewport.y; - rez.left += viewport.x; - } - - rez.top = getValue(Math.max(rez.top, rez.top + ((viewport.h - height) * current.topRatio))); - rez.left = getValue(Math.max(rez.left, rez.left + ((viewport.w - width) * current.leftRatio))); - - return rez; - }, - - _afterZoomIn: function () { - var current = F.current; - - if (!current) { - return; - } - - F.isOpen = F.isOpened = true; - - F.wrap.css('overflow', 'visible').addClass('fancybox-opened'); - - F.update(); - - // Assign a click event - if ( current.closeClick || (current.nextClick && F.group.length > 1) ) { - F.inner.css('cursor', 'pointer').bind('click.fb', function(e) { - if (!$(e.target).is('a') && !$(e.target).parent().is('a')) { - e.preventDefault(); - - F[ current.closeClick ? 'close' : 'next' ](); - } - }); - } - - // Create a close button - if (current.closeBtn) { - $(current.tpl.closeBtn).appendTo(F.skin).bind('click.fb', function(e) { - e.preventDefault(); - - F.close(); - }); - } - - // Create navigation arrows - if (current.arrows && F.group.length > 1) { - if (current.loop || current.index > 0) { - $(current.tpl.prev).appendTo(F.outer).bind('click.fb', F.prev); - } - - if (current.loop || current.index < F.group.length - 1) { - $(current.tpl.next).appendTo(F.outer).bind('click.fb', F.next); - } - } - - F.trigger('afterShow'); - - // Stop the slideshow if this is the last item - if (!current.loop && current.index === current.group.length - 1) { - F.play( false ); - - } else if (F.opts.autoPlay && !F.player.isActive) { - F.opts.autoPlay = false; - - F.play(); - } - }, - - _afterZoomOut: function ( obj ) { - obj = obj || F.current; - - $('.fancybox-wrap').trigger('onReset').remove(); - - $.extend(F, { - group : {}, - opts : {}, - router : false, - current : null, - isActive : false, - isOpened : false, - isOpen : false, - isClosing : false, - wrap : null, - skin : null, - outer : null, - inner : null - }); - - F.trigger('afterClose', obj); - } - }); - - /* - * Default transitions - */ - - F.transitions = { - getOrigPosition: function () { - var current = F.current, - element = current.element, - orig = current.orig, - pos = {}, - width = 50, - height = 50, - hPadding = current.hPadding, - wPadding = current.wPadding, - viewport = F.getViewport(); - - if (!orig && current.isDom && element.is(':visible')) { - orig = element.find('img:first'); - - if (!orig.length) { - orig = element; - } - } - - if (isQuery(orig)) { - pos = orig.offset(); - - if (orig.is('img')) { - width = orig.outerWidth(); - height = orig.outerHeight(); - } - - } else { - pos.top = viewport.y + (viewport.h - height) * current.topRatio; - pos.left = viewport.x + (viewport.w - width) * current.leftRatio; - } - - if (F.wrap.css('position') === 'fixed' || current.locked) { - pos.top -= viewport.y; - pos.left -= viewport.x; - } - - pos = { - top : getValue(pos.top - hPadding * current.topRatio), - left : getValue(pos.left - wPadding * current.leftRatio), - width : getValue(width + wPadding), - height : getValue(height + hPadding) - }; - - return pos; - }, - - step: function (now, fx) { - var ratio, - padding, - value, - prop = fx.prop, - current = F.current, - wrapSpace = current.wrapSpace, - skinSpace = current.skinSpace; - - if (prop === 'width' || prop === 'height') { - ratio = fx.end === fx.start ? 1 : (now - fx.start) / (fx.end - fx.start); - - if (F.isClosing) { - ratio = 1 - ratio; - } - - padding = prop === 'width' ? current.wPadding : current.hPadding; - value = now - padding; - - F.skin[ prop ]( getScalar( prop === 'width' ? value : value - (wrapSpace * ratio) ) ); - F.inner[ prop ]( getScalar( prop === 'width' ? value : value - (wrapSpace * ratio) - (skinSpace * ratio) ) ); - } - }, - - zoomIn: function () { - var current = F.current, - startPos = current.pos, - effect = current.openEffect, - elastic = effect === 'elastic', - endPos = $.extend({opacity : 1}, startPos); - - // Remove "position" property that breaks older IE - delete endPos.position; - - if (elastic) { - startPos = this.getOrigPosition(); - - if (current.openOpacity) { - startPos.opacity = 0.1; - } - - } else if (effect === 'fade') { - startPos.opacity = 0.1; - } - - F.wrap.css(startPos).animate(endPos, { - duration : effect === 'none' ? 0 : current.openSpeed, - easing : current.openEasing, - step : elastic ? this.step : null, - complete : F._afterZoomIn - }); - }, - - zoomOut: function () { - var current = F.current, - effect = current.closeEffect, - elastic = effect === 'elastic', - endPos = {opacity : 0.1}; - - if (elastic) { - endPos = this.getOrigPosition(); - - if (current.closeOpacity) { - endPos.opacity = 0.1; - } - } - - F.wrap.animate(endPos, { - duration : effect === 'none' ? 0 : current.closeSpeed, - easing : current.closeEasing, - step : elastic ? this.step : null, - complete : F._afterZoomOut - }); - }, - - changeIn: function () { - var current = F.current, - effect = current.nextEffect, - startPos = current.pos, - endPos = { opacity : 1 }, - direction = F.direction, - distance = 200, - field; - - startPos.opacity = 0.1; - - if (effect === 'elastic') { - field = direction === 'down' || direction === 'up' ? 'top' : 'left'; - - if (direction === 'down' || direction === 'right') { - startPos[ field ] = getValue(getScalar(startPos[ field ]) - distance); - endPos[ field ] = '+=' + distance + 'px'; - - } else { - startPos[ field ] = getValue(getScalar(startPos[ field ]) + distance); - endPos[ field ] = '-=' + distance + 'px'; - } - } - - // Workaround for http://bugs.jquery.com/ticket/12273 - if (effect === 'none') { - F._afterZoomIn(); - - } else { - F.wrap.css(startPos).animate(endPos, { - duration : current.nextSpeed, - easing : current.nextEasing, - complete : F._afterZoomIn - }); - } - }, - - changeOut: function () { - var previous = F.previous, - effect = previous.prevEffect, - endPos = { opacity : 0.1 }, - direction = F.direction, - distance = 200; - - if (effect === 'elastic') { - endPos[ direction === 'down' || direction === 'up' ? 'top' : 'left' ] = ( direction === 'up' || direction === 'left' ? '-' : '+' ) + '=' + distance + 'px'; - } - - previous.wrap.animate(endPos, { - duration : effect === 'none' ? 0 : previous.prevSpeed, - easing : previous.prevEasing, - complete : function () { - $(this).trigger('onReset').remove(); - } - }); - } - }; - - /* - * Overlay helper - */ - - F.helpers.overlay = { - defaults : { - closeClick : true, // if true, fancyBox will be closed when user clicks on the overlay - speedOut : 200, // duration of fadeOut animation - showEarly : true, // indicates if should be opened immediately or wait until the content is ready - css : {}, // custom CSS properties - locked : !isTouch, // if true, the content will be locked into overlay - fixed : true // if false, the overlay CSS position property will not be set to "fixed" - }, - - overlay : null, // current handle - fixed : false, // indicates if the overlay has position "fixed" - - // Public methods - create : function(opts) { - opts = $.extend({}, this.defaults, opts); - - if (this.overlay) { - this.close(); - } - - this.overlay = $('
').appendTo( 'body' ); - this.fixed = false; - - if (opts.fixed && F.defaults.fixed) { - this.overlay.addClass('fancybox-overlay-fixed'); - - this.fixed = true; - } - }, - - open : function(opts) { - var that = this; - - opts = $.extend({}, this.defaults, opts); - - if (this.overlay) { - this.overlay.unbind('.overlay').width('auto').height('auto'); - - } else { - this.create(opts); - } - - if (!this.fixed) { - W.bind('resize.overlay', $.proxy( this.update, this) ); - - this.update(); - } - - if (opts.closeClick) { - this.overlay.bind('click.overlay', function(e) { - if ($(e.target).hasClass('fancybox-overlay')) { - if (F.isActive) { - F.close(); - } else { - that.close(); - } - } - }); - } - - this.overlay.css( opts.css ).show(); - }, - - close : function() { - $('.fancybox-overlay').remove(); - - W.unbind('resize.overlay'); - - this.overlay = null; - - if (this.margin !== false) { - $('body').css('margin-right', this.margin); - - this.margin = false; - } - - if (this.el) { - this.el.removeClass('fancybox-lock'); - } - }, - - // Private, callbacks - - update : function () { - var width = '100%', offsetWidth; - - // Reset width/height so it will not mess - this.overlay.width(width).height('100%'); - - // jQuery does not return reliable result for IE - if (IE) { - offsetWidth = Math.max(document.documentElement.offsetWidth, document.body.offsetWidth); - - if (D.width() > offsetWidth) { - width = D.width(); - } - - } else if (D.width() > W.width()) { - width = D.width(); - } - - this.overlay.width(width).height(D.height()); - }, - - // This is where we can manipulate DOM, because later it would cause iframes to reload - onReady : function (opts, obj) { - $('.fancybox-overlay').stop(true, true); - - if (!this.overlay) { - this.margin = D.height() > W.height() || $('body').css('overflow-y') === 'scroll' ? $('body').css('margin-right') : false; - this.el = document.all && !document.querySelector ? $('html') : $('body'); - - this.create(opts); - } - - if (opts.locked && this.fixed) { - obj.locked = this.overlay.append( obj.wrap ); - obj.fixed = false; - } - - if (opts.showEarly === true) { - this.beforeShow.apply(this, arguments); - } - }, - - beforeShow : function(opts, obj) { - if (obj.locked) { - this.el.addClass('fancybox-lock'); - - if (this.margin !== false) { - $('body').css('margin-right', getScalar( this.margin ) + obj.scrollbarWidth); - } - } - - this.open(opts); - }, - - onUpdate : function() { - if (!this.fixed) { - this.update(); - } - }, - - afterClose: function (opts) { - // Remove overlay if exists and fancyBox is not opening - // (e.g., it is not being open using afterClose callback) - if (this.overlay && !F.isActive) { - this.overlay.fadeOut(opts.speedOut, $.proxy( this.close, this )); - } - } - }; - - /* - * Title helper - */ - - F.helpers.title = { - defaults : { - type : 'float', // 'float', 'inside', 'outside' or 'over', - position : 'bottom' // 'top' or 'bottom' - }, - - beforeShow: function (opts) { - var current = F.current, - text = current.title, - type = opts.type, - title, - target; - - if ($.isFunction(text)) { - text = text.call(current.element, current); - } - - if (!isString(text) || $.trim(text) === '') { - return; - } - - title = $('
' + text + '
'); - - switch (type) { - case 'inside': - target = F.skin; - break; - - case 'outside': - target = F.wrap; - break; - - case 'over': - target = F.inner; - break; - - default: // 'float' - target = F.skin; - - title.appendTo('body'); - - if (IE) { - title.width( title.width() ); - } - - title.wrapInner(''); - - //Increase bottom margin so this title will also fit into viewport - F.current.margin[2] += Math.abs( getScalar(title.css('margin-bottom')) ); - break; - } - - title[ (opts.position === 'top' ? 'prependTo' : 'appendTo') ](target); - } - }; - - // jQuery plugin initialization - $.fn.fancybox = function (options) { - var index, - that = $(this), - selector = this.selector || '', - run = function(e) { - var what = $(this).blur(), idx = index, relType, relVal; - - if (!(e.ctrlKey || e.altKey || e.shiftKey || e.metaKey) && !what.is('.fancybox-wrap')) { - relType = options.groupAttr || 'data-fancybox-group'; - relVal = what.attr(relType); - - if (!relVal) { - relType = 'rel'; - relVal = what.get(0)[ relType ]; - } - - if (relVal && relVal !== '' && relVal !== 'nofollow') { - what = selector.length ? $(selector) : that; - what = what.filter('[' + relType + '="' + relVal + '"]'); - idx = what.index(this); - } - - options.index = idx; - - // Stop an event from bubbling if everything is fine - if (F.open(what, options) !== false) { - e.preventDefault(); - } - } - }; - - options = options || {}; - index = options.index || 0; - - if (!selector || options.live === false) { - that.unbind('click.fb-start').bind('click.fb-start', run); - - } else { - D.undelegate(selector, 'click.fb-start').delegate(selector + ":not('.fancybox-item, .fancybox-nav')", 'click.fb-start', run); - } - - this.filter('[data-fancybox-start=1]').trigger('click'); - - return this; - }; - - // Tests that need a body at doc ready - D.ready(function() { - if ( $.scrollbarWidth === undefined ) { - // http://benalman.com/projects/jquery-misc-plugins/#scrollbarwidth - $.scrollbarWidth = function() { - var parent = $('
').appendTo('body'), - child = parent.children(), - width = child.innerWidth() - child.height( 99 ).innerWidth(); - - parent.remove(); - - return width; - }; - } - - if ( $.support.fixedPosition === undefined ) { - $.support.fixedPosition = (function() { - var elem = $('
').appendTo('body'), - fixed = ( elem[0].offsetTop === 20 || elem[0].offsetTop === 15 ); - - elem.remove(); - - return fixed; - }()); - } - - $.extend(F.defaults, { - scrollbarWidth : $.scrollbarWidth(), - fixed : $.support.fixedPosition, - parent : $('body') - }); - }); - -}(window, document, jQuery)); \ No newline at end of file diff --git a/library/fancybox/jquery.fancybox.pack.js b/library/fancybox/jquery.fancybox.pack.js deleted file mode 100644 index c8947a08b5..0000000000 --- a/library/fancybox/jquery.fancybox.pack.js +++ /dev/null @@ -1,44 +0,0 @@ -(function(C,z,f,r){var q=f(C),n=f(z),b=f.fancybox=function(){b.open.apply(this,arguments)},H=navigator.userAgent.match(/msie/i),w=null,s=z.createTouch!==r,t=function(a){return a&&a.hasOwnProperty&&a instanceof f},p=function(a){return a&&"string"===f.type(a)},F=function(a){return p(a)&&0
',image:'',iframe:'",error:'

The requested content cannot be loaded.
Please try again later.

',closeBtn:'',next:'',prev:''},openEffect:"fade",openSpeed:250,openEasing:"swing",openOpacity:!0, -openMethod:"zoomIn",closeEffect:"fade",closeSpeed:250,closeEasing:"swing",closeOpacity:!0,closeMethod:"zoomOut",nextEffect:"elastic",nextSpeed:250,nextEasing:"swing",nextMethod:"changeIn",prevEffect:"elastic",prevSpeed:250,prevEasing:"swing",prevMethod:"changeOut",helpers:{overlay:!0,title:!0},onCancel:f.noop,beforeLoad:f.noop,afterLoad:f.noop,beforeShow:f.noop,afterShow:f.noop,beforeChange:f.noop,beforeClose:f.noop,afterClose:f.noop},group:{},opts:{},previous:null,coming:null,current:null,isActive:!1, -isOpen:!1,isOpened:!1,wrap:null,skin:null,outer:null,inner:null,player:{timer:null,isActive:!1},ajaxLoad:null,imgPreload:null,transitions:{},helpers:{},open:function(a,d){if(a&&(f.isPlainObject(d)||(d={}),!1!==b.close(!0)))return f.isArray(a)||(a=t(a)?f(a).get():[a]),f.each(a,function(e,c){var k={},g,h,j,m,l;"object"===f.type(c)&&(c.nodeType&&(c=f(c)),t(c)?(k={href:c.data("fancybox-href")||c.attr("href"),title:c.data("fancybox-title")||c.attr("title"),isDom:!0,element:c},f.metadata&&f.extend(!0,k, -c.metadata())):k=c);g=d.href||k.href||(p(c)?c:null);h=d.title!==r?d.title:k.title||"";m=(j=d.content||k.content)?"html":d.type||k.type;!m&&k.isDom&&(m=c.data("fancybox-type"),m||(m=(m=c.prop("class").match(/fancybox\.(\w+)/))?m[1]:null));p(g)&&(m||(b.isImage(g)?m="image":b.isSWF(g)?m="swf":"#"===g.charAt(0)?m="inline":p(c)&&(m="html",j=c)),"ajax"===m&&(l=g.split(/\s+/,2),g=l.shift(),l=l.shift()));j||("inline"===m?g?j=f(p(g)?g.replace(/.*(?=#[^\s]+$)/,""):g):k.isDom&&(j=c):"html"===m?j=g:!m&&(!g&& -k.isDom)&&(m="inline",j=c));f.extend(k,{href:g,type:m,content:j,title:h,selector:l});a[e]=k}),b.opts=f.extend(!0,{},b.defaults,d),d.keys!==r&&(b.opts.keys=d.keys?f.extend({},b.defaults.keys,d.keys):!1),b.group=a,b._start(b.opts.index)},cancel:function(){var a=b.coming;a&&!1!==b.trigger("onCancel")&&(b.hideLoading(),b.ajaxLoad&&b.ajaxLoad.abort(),b.ajaxLoad=null,b.imgPreload&&(b.imgPreload.onload=b.imgPreload.onerror=null),a.wrap&&a.wrap.stop(!0,!0).trigger("onReset").remove(),b.coming=null,b.current|| -b._afterZoomOut(a))},close:function(a){b.cancel();!1!==b.trigger("beforeClose")&&(b.unbindEvents(),b.isActive&&(!b.isOpen||!0===a?(f(".fancybox-wrap").stop(!0).trigger("onReset").remove(),b._afterZoomOut()):(b.isOpen=b.isOpened=!1,b.isClosing=!0,f(".fancybox-item, .fancybox-nav").remove(),b.wrap.stop(!0,!0).removeClass("fancybox-opened"),b.transitions[b.current.closeMethod]())))},play:function(a){var d=function(){clearTimeout(b.player.timer)},e=function(){d();b.current&&b.player.isActive&&(b.player.timer= -setTimeout(b.next,b.current.playSpeed))},c=function(){d();f("body").unbind(".player");b.player.isActive=!1;b.trigger("onPlayEnd")};if(!0===a||!b.player.isActive&&!1!==a){if(b.current&&(b.current.loop||b.current.index=c.index?"next":"prev"],b.router=e||"jumpto",c.loop&&(0>a&&(a=c.group.length+a%c.group.length),a%=c.group.length),c.group[a]!==r&&(b.cancel(),b._start(a)))},reposition:function(a,d){var e=b.current,c=e?e.wrap:null,k;c&&(k=b._getPosition(d),a&&"scroll"===a.type?(delete k.position,c.stop(!0,!0).animate(k,200)):(c.css(k),e.pos=f.extend({}, -e.dim,k)))},update:function(a){var d=a&&a.type,e=!d||"orientationchange"===d;e&&(clearTimeout(w),w=null);b.isOpen&&!w&&(w=setTimeout(function(){var c=b.current;c&&!b.isClosing&&(b.wrap.removeClass("fancybox-tmp"),(e||"load"===d||"resize"===d&&c.autoResize)&&b._setDimension(),"scroll"===d&&c.canShrink||b.reposition(a),b.trigger("onUpdate"),w=null)},e&&!s?0:300))},toggle:function(a){b.isOpen&&(b.current.fitToView="boolean"===f.type(a)?a:!b.current.fitToView,s&&(b.wrap.removeAttr("style").addClass("fancybox-tmp"), -b.trigger("onUpdate")),b.update())},hideLoading:function(){n.unbind(".loading");f("#fancybox-loading").remove()},showLoading:function(){var a,d;b.hideLoading();a=f('
').click(b.cancel).appendTo("body");n.bind("keydown.loading",function(a){if(27===(a.which||a.keyCode))a.preventDefault(),b.cancel()});b.defaults.fixed||(d=b.getViewport(),a.css({position:"absolute",top:0.5*d.h+d.y,left:0.5*d.w+d.x}))},getViewport:function(){var a=b.current&&b.current.locked|| -!1,d={x:q.scrollLeft(),y:q.scrollTop()};a?(d.w=a[0].clientWidth,d.h=a[0].clientHeight):(d.w=s&&C.innerWidth?C.innerWidth:q.width(),d.h=s&&C.innerHeight?C.innerHeight:q.height());return d},unbindEvents:function(){b.wrap&&t(b.wrap)&&b.wrap.unbind(".fb");n.unbind(".fb");q.unbind(".fb")},bindEvents:function(){var a=b.current,d;a&&(q.bind("orientationchange.fb"+(s?"":" resize.fb")+(a.autoCenter&&!a.locked?" scroll.fb":""),b.update),(d=a.keys)&&n.bind("keydown.fb",function(e){var c=e.which||e.keyCode,k= -e.target||e.srcElement;if(27===c&&b.coming)return!1;!e.ctrlKey&&(!e.altKey&&!e.shiftKey&&!e.metaKey&&(!k||!k.type&&!f(k).is("[contenteditable]")))&&f.each(d,function(d,k){if(1h[0].clientWidth||h[0].clientHeight&&h[0].scrollHeight>h[0].clientHeight),h=f(h).parent();if(0!==c&&!j&&1g||0>k)b.next(0>g?"up":"right");d.preventDefault()}}))},trigger:function(a,d){var e,c=d||b.coming||b.current;if(c){f.isFunction(c[a])&&(e=c[a].apply(c,Array.prototype.slice.call(arguments,1)));if(!1===e)return!1;c.helpers&&f.each(c.helpers,function(d, -e){e&&(b.helpers[d]&&f.isFunction(b.helpers[d][a]))&&(e=f.extend(!0,{},b.helpers[d].defaults,e),b.helpers[d][a](e,c))});f.event.trigger(a+".fb")}},isImage:function(a){return p(a)&&a.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp)((\?|#).*)?$)/i)},isSWF:function(a){return p(a)&&a.match(/\.(swf)((\?|#).*)?$/i)},_start:function(a){var d={},e,c;a=l(a);e=b.group[a]||null;if(!e)return!1;d=f.extend(!0,{},b.opts,e);e=d.margin;c=d.padding;"number"===f.type(e)&&(d.margin=[e,e,e,e]);"number"===f.type(c)&& -(d.padding=[c,c,c,c]);d.modal&&f.extend(!0,d,{closeBtn:!1,closeClick:!1,nextClick:!1,arrows:!1,mouseWheel:!1,keys:null,helpers:{overlay:{closeClick:!1}}});d.autoSize&&(d.autoWidth=d.autoHeight=!0);"auto"===d.width&&(d.autoWidth=!0);"auto"===d.height&&(d.autoHeight=!0);d.group=b.group;d.index=a;b.coming=d;if(!1===b.trigger("beforeLoad"))b.coming=null;else{c=d.type;e=d.href;if(!c)return b.coming=null,b.current&&b.router&&"jumpto"!==b.router?(b.current.index=a,b[b.router](b.direction)):!1;b.isActive= -!0;if("image"===c||"swf"===c)d.autoHeight=d.autoWidth=!1,d.scrolling="visible";"image"===c&&(d.aspectRatio=!0);"iframe"===c&&s&&(d.scrolling="scroll");d.wrap=f(d.tpl.wrap).addClass("fancybox-"+(s?"mobile":"desktop")+" fancybox-type-"+c+" fancybox-tmp "+d.wrapCSS).appendTo(d.parent||"body");f.extend(d,{skin:f(".fancybox-skin",d.wrap),outer:f(".fancybox-outer",d.wrap),inner:f(".fancybox-inner",d.wrap)});f.each(["Top","Right","Bottom","Left"],function(a,b){d.skin.css("padding"+b,x(d.padding[a]))});b.trigger("onReady"); -if("inline"===c||"html"===c){if(!d.content||!d.content.length)return b._error("content")}else if(!e)return b._error("href");"image"===c?b._loadImage():"ajax"===c?b._loadAjax():"iframe"===c?b._loadIframe():b._afterLoad()}},_error:function(a){f.extend(b.coming,{type:"html",autoWidth:!0,autoHeight:!0,minWidth:0,minHeight:0,scrolling:"no",hasError:a,content:b.coming.tpl.error});b._afterLoad()},_loadImage:function(){var a=b.imgPreload=new Image;a.onload=function(){this.onload=this.onerror=null;b.coming.width= -this.width;b.coming.height=this.height;b._afterLoad()};a.onerror=function(){this.onload=this.onerror=null;b._error("image")};a.src=b.coming.href;!0!==a.complete&&b.showLoading()},_loadAjax:function(){var a=b.coming;b.showLoading();b.ajaxLoad=f.ajax(f.extend({},a.ajax,{url:a.href,error:function(a,e){b.coming&&"abort"!==e?b._error("ajax",a):b.hideLoading()},success:function(d,e){"success"===e&&(a.content=d,b._afterLoad())}}))},_loadIframe:function(){var a=b.coming,d=f(a.tpl.iframe.replace(/\{rnd\}/g, -(new Date).getTime())).attr("scrolling",s?"auto":a.iframe.scrolling).attr("src",a.href);f(a.wrap).bind("onReset",function(){try{f(this).find("iframe").hide().attr("src","//about:blank").end().empty()}catch(a){}});a.iframe.preload&&(b.showLoading(),d.one("load",function(){f(this).data("ready",1);s||f(this).bind("load.fb",b.update);f(this).parents(".fancybox-wrap").width("100%").removeClass("fancybox-tmp").show();b._afterLoad()}));a.content=d.appendTo(a.inner);a.iframe.preload||b._afterLoad()},_preloadImages:function(){var a= -b.group,d=b.current,e=a.length,c=d.preload?Math.min(d.preload,e-1):0,f,g;for(g=1;g<=c;g+=1)f=a[(d.index+g)%e],"image"===f.type&&f.href&&((new Image).src=f.href)},_afterLoad:function(){var a=b.coming,d=b.current,e,c,k,g,h;b.hideLoading();if(a&&!1!==b.isActive)if(!1===b.trigger("afterLoad",a,d))a.wrap.stop(!0).trigger("onReset").remove(),b.coming=null;else{d&&(b.trigger("beforeChange",d),d.wrap.stop(!0).removeClass("fancybox-opened").find(".fancybox-item, .fancybox-nav").remove());b.unbindEvents(); -e=a.content;c=a.type;k=a.scrolling;f.extend(b,{wrap:a.wrap,skin:a.skin,outer:a.outer,inner:a.inner,current:a,previous:d});g=a.href;switch(c){case "inline":case "ajax":case "html":a.selector?e=f("
").html(e).find(a.selector):t(e)&&(e.data("fancybox-placeholder")||e.data("fancybox-placeholder",f('
').insertAfter(e).hide()),e=e.show().detach(),a.wrap.bind("onReset",function(){f(this).find(e).length&&e.hide().replaceAll(e.data("fancybox-placeholder")).data("fancybox-placeholder", -!1)}));break;case "image":e=a.tpl.image.replace("{href}",g);break;case "swf":e='',h="",f.each(a.swf,function(a,b){e+='';h+=" "+a+'="'+b+'"'}),e+='"}(!t(e)||!e.parent().is(a.inner))&&a.inner.append(e);b.trigger("beforeShow"); -a.inner.css("overflow","yes"===k?"scroll":"no"===k?"hidden":k);b._setDimension();b.reposition();b.isOpen=!1;b.coming=null;b.bindEvents();if(b.isOpened){if(d.prevMethod)b.transitions[d.prevMethod]()}else f(".fancybox-wrap").not(a.wrap).stop(!0).trigger("onReset").remove();b.transitions[b.isOpened?a.nextMethod:a.openMethod]();b._preloadImages()}},_setDimension:function(){var a=b.getViewport(),d=0,e=!1,c=!1,e=b.wrap,k=b.skin,g=b.inner,h=b.current,c=h.width,j=h.height,m=h.minWidth,u=h.minHeight,n=h.maxWidth, -v=h.maxHeight,s=h.scrolling,q=h.scrollOutside?h.scrollbarWidth:0,y=h.margin,p=l(y[1]+y[3]),r=l(y[0]+y[2]),z,A,t,D,B,G,C,E,w;e.add(k).add(g).width("auto").height("auto").removeClass("fancybox-tmp");y=l(k.outerWidth(!0)-k.width());z=l(k.outerHeight(!0)-k.height());A=p+y;t=r+z;D=F(c)?(a.w-A)*l(c)/100:c;B=F(j)?(a.h-t)*l(j)/100:j;if("iframe"===h.type){if(w=h.content,h.autoHeight&&1===w.data("ready"))try{w[0].contentWindow.document.location&&(g.width(D).height(9999),G=w.contents().find("body"),q&&G.css("overflow-x", -"hidden"),B=G.height())}catch(H){}}else if(h.autoWidth||h.autoHeight)g.addClass("fancybox-tmp"),h.autoWidth||g.width(D),h.autoHeight||g.height(B),h.autoWidth&&(D=g.width()),h.autoHeight&&(B=g.height()),g.removeClass("fancybox-tmp");c=l(D);j=l(B);E=D/B;m=l(F(m)?l(m,"w")-A:m);n=l(F(n)?l(n,"w")-A:n);u=l(F(u)?l(u,"h")-t:u);v=l(F(v)?l(v,"h")-t:v);G=n;C=v;h.fitToView&&(n=Math.min(a.w-A,n),v=Math.min(a.h-t,v));A=a.w-p;r=a.h-r;h.aspectRatio?(c>n&&(c=n,j=l(c/E)),j>v&&(j=v,c=l(j*E)),cA||p>r)&&(c>m&&j>u)&&!(19n&&(c=n,j=l(c/E)),g.width(c).height(j),e.width(c+y),a=e.width(),p=e.height();else c=Math.max(m,Math.min(c,c-(a-A))),j=Math.max(u,Math.min(j,j-(p-r)));q&&("auto"===s&&jA||p>r)&&c>m&&j>u;c=h.aspectRatio?cu&&j
').appendTo("body"); -this.fixed=!1;a.fixed&&b.defaults.fixed&&(this.overlay.addClass("fancybox-overlay-fixed"),this.fixed=!0)},open:function(a){var d=this;a=f.extend({},this.defaults,a);this.overlay?this.overlay.unbind(".overlay").width("auto").height("auto"):this.create(a);this.fixed||(q.bind("resize.overlay",f.proxy(this.update,this)),this.update());a.closeClick&&this.overlay.bind("click.overlay",function(a){f(a.target).hasClass("fancybox-overlay")&&(b.isActive?b.close():d.close())});this.overlay.css(a.css).show()}, -close:function(){f(".fancybox-overlay").remove();q.unbind("resize.overlay");this.overlay=null;!1!==this.margin&&(f("body").css("margin-right",this.margin),this.margin=!1);this.el&&this.el.removeClass("fancybox-lock")},update:function(){var a="100%",b;this.overlay.width(a).height("100%");H?(b=Math.max(z.documentElement.offsetWidth,z.body.offsetWidth),n.width()>b&&(a=n.width())):n.width()>q.width()&&(a=n.width());this.overlay.width(a).height(n.height())},onReady:function(a,b){f(".fancybox-overlay").stop(!0, -!0);this.overlay||(this.margin=n.height()>q.height()||"scroll"===f("body").css("overflow-y")?f("body").css("margin-right"):!1,this.el=z.all&&!z.querySelector?f("html"):f("body"),this.create(a));a.locked&&this.fixed&&(b.locked=this.overlay.append(b.wrap),b.fixed=!1);!0===a.showEarly&&this.beforeShow.apply(this,arguments)},beforeShow:function(a,b){b.locked&&(this.el.addClass("fancybox-lock"),!1!==this.margin&&f("body").css("margin-right",l(this.margin)+b.scrollbarWidth));this.open(a)},onUpdate:function(){this.fixed|| -this.update()},afterClose:function(a){this.overlay&&!b.isActive&&this.overlay.fadeOut(a.speedOut,f.proxy(this.close,this))}};b.helpers.title={defaults:{type:"float",position:"bottom"},beforeShow:function(a){var d=b.current,e=d.title,c=a.type;f.isFunction(e)&&(e=e.call(d.element,d));if(p(e)&&""!==f.trim(e)){d=f('
'+e+"
");switch(c){case "inside":c=b.skin;break;case "outside":c=b.wrap;break;case "over":c=b.inner;break;default:c=b.skin,d.appendTo("body"), -H&&d.width(d.width()),d.wrapInner(''),b.current.margin[2]+=Math.abs(l(d.css("margin-bottom")))}d["top"===a.position?"prependTo":"appendTo"](c)}}};f.fn.fancybox=function(a){var d,e=f(this),c=this.selector||"",k=function(g){var h=f(this).blur(),j=d,k,l;!g.ctrlKey&&(!g.altKey&&!g.shiftKey&&!g.metaKey)&&!h.is(".fancybox-wrap")&&(k=a.groupAttr||"data-fancybox-group",l=h.attr(k),l||(k="rel",l=h.get(0)[k]),l&&(""!==l&&"nofollow"!==l)&&(h=c.length?f(c):e,h=h.filter("["+k+'="'+l+ -'"]'),j=h.index(this)),a.index=j,!1!==b.open(h,a)&&g.preventDefault())};a=a||{};d=a.index||0;!c||!1===a.live?e.unbind("click.fb-start").bind("click.fb-start",k):n.undelegate(c,"click.fb-start").delegate(c+":not('.fancybox-item, .fancybox-nav')","click.fb-start",k);this.filter("[data-fancybox-start=1]").trigger("click");return this};n.ready(function(){f.scrollbarWidth===r&&(f.scrollbarWidth=function(){var a=f('
').appendTo("body"),b=a.children(), -b=b.innerWidth()-b.height(99).innerWidth();a.remove();return b});if(f.support.fixedPosition===r){var a=f.support,d=f('
').appendTo("body"),e=20===d[0].offsetTop||15===d[0].offsetTop;d.remove();a.fixedPosition=e}f.extend(b.defaults,{scrollbarWidth:f.scrollbarWidth(),fixed:f.support.fixedPosition,parent:f("body")})})})(window,document,jQuery); \ No newline at end of file diff --git a/library/fullcalendar/GPL-LICENSE.txt b/library/fullcalendar/GPL-LICENSE.txt deleted file mode 100644 index 11dddd00ef..0000000000 --- a/library/fullcalendar/GPL-LICENSE.txt +++ /dev/null @@ -1,278 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. diff --git a/library/fullcalendar/changelog.txt b/library/fullcalendar/changelog.txt index 17b31f8622..829971463e 100644 --- a/library/fullcalendar/changelog.txt +++ b/library/fullcalendar/changelog.txt @@ -1,4 +1,68 @@ +version 1.6.4 (9/1/13) + - better algorithm for positioning timed agenda events (issue 1115) + - `slotEventOverlap` option to tweak timed agenda event overlapping (issue 218) + - selection bug when slot height is customized (issue 1035) + - supply view argument in `loading` callback (issue 1018) + - fixed week number not displaying in agenda views (issue 1951) + - fixed fullCalendar not initializing with no options (issue 1356) + - NPM's package.json, no more warnings or errors (issue 1762) + - building the bower component should output bower.json instead of component.json (PR 125) + - use bower internally for fetching new versions of jQuery and jQuery UI + +version 1.6.3 (8/10/13) + - viewRender callback (PR 15) + - viewDestroy callback (PR 15) + - eventDestroy callback (PR 111) + - handleWindowResize option (PR 54) + - eventStartEditable/startEditable options (PR 49) + - eventDurationEditable/durationEditable options (PR 49) + - specify function for $.ajax `data` parameter for JSON event sources (PR 59) + - fixed bug with agenda event dropping in wrong column (PR 55) + - easier event element z-index customization (PR 58) + - classNames on past/future days (PR 88) + - allow null/undefined event titles (PR 84) + - small optimize for agenda event rendering (PR 56) + - deprecated: + - viewDisplay + - disableDragging + - disableResizing + - bundled with latest jQuery (1.10.2) and jQuery UI (1.10.3) + +version 1.6.2 (7/18/13) + - hiddenDays option (issue 686) + - bugfix: when eventRender returns false, incorrect stacking of events (issue 762) + - bugfix: couldn't change event.backgroundImage when calling updateEvent (thx stephenharris) + +version 1.6.1 (4/14/13) + - fixed event inner content overflow bug (issue 1783) + - fixed table header className bug (1772) + - removed text-shadow on events (better for general use, thx tkrotoff) + +version 1.6.0 (3/18/13) + - visual facelift, with bootstrap-inspired buttons and colors + - simplified HTML/CSS for events and buttons + - dayRender, for modifying a day cell (issue 191, thx althaus) + - week numbers on side of calendar (issue 295) + - weekNumber + - weekNumberCalculation + - weekNumberTitle + - "W" formatting variable + - finer snapping granularity for agenda view events (issue 495, thx ms-doodle-com) + - eventAfterAllRender (issue 753, thx pdrakeweb) + - eventDataTransform (thx joeyspo) + - data-date attributes on cells (thx Jae) + - expose $.fullCalendar.dateFormatters + - when clicking fast on buttons, prevent text selection + - bundled with latest jQuery (1.9.1) and jQuery UI (1.10.2) + - Grunt/Lumbar build system for internal development + - build for Bower package manager + - build for jQuery plugin site + +version 1.5.4 (9/5/12) + - made compatible with jQuery 1.8.* (thx archaeron) + - bundled with jQuery 1.8.1 and jQuery UI 1.8.23 + version 1.5.3 (2/6/12) - fixed dragging issue with jQuery UI 1.8.16 (issue 1168) - bundled with jQuery 1.7.1 and jQuery UI 1.8.17 diff --git a/library/fullcalendar/fullcalendar.css b/library/fullcalendar/fullcalendar.css index 04f118493a..92fe47f202 100644 --- a/library/fullcalendar/fullcalendar.css +++ b/library/fullcalendar/fullcalendar.css @@ -1,12 +1,7 @@ -/* - * FullCalendar v1.5.3 Stylesheet - * - * Copyright (c) 2011 Adam Shaw - * Dual licensed under the MIT and GPL licenses, located in - * MIT-LICENSE.txt and GPL-LICENSE.txt respectively. - * - * Date: Mon Feb 6 22:40:40 2012 -0800 - * +/*! + * FullCalendar v1.6.4 Stylesheet + * Docs & License: http://arshaw.com/fullcalendar/ + * (c) 2013 Adam Shaw */ @@ -79,11 +74,8 @@ html .fc, margin-right: -1px; } -.fc-header .fc-corner-right { - margin-right: 1px; /* back to normal */ - } - -.fc-header .ui-corner-right { +.fc-header .fc-corner-right, /* non-theme */ +.fc-header .ui-corner-right { /* theme */ margin-right: 0; /* back to normal */ } @@ -110,10 +102,11 @@ html .fc, .fc-content { clear: both; + zoom: 1; /* for IE7, gives accurate coordinates for [un]freezeContentHeight */ } .fc-view { - width: 100%; /* needed for view switching (when view is absolute) */ + width: 100%; overflow: hidden; } @@ -124,17 +117,17 @@ html .fc, .fc-widget-header, /* , usually */ .fc-widget-content { /* , usually */ - border: 1px solid #ccc; + border: 1px solid #ddd; } .fc-state-highlight { /* today cell */ /* TODO: add .fc-today to */ - background: #ffc; + background: #fcf8e3; } .fc-cell-overlay { /* semi-transparent rectangle while dragging */ - background: #9cf; - opacity: .2; - filter: alpha(opacity=20); /* for IE */ + background: #bce8f1; + opacity: .3; + filter: alpha(opacity=30); /* for IE */ } @@ -145,43 +138,54 @@ html .fc, .fc-button { position: relative; display: inline-block; + padding: 0 .6em; + overflow: hidden; + height: 1.9em; + line-height: 1.9em; + white-space: nowrap; cursor: pointer; } .fc-state-default { /* non-theme */ - border-style: solid; - border-width: 1px 0; + border: 1px solid; } - -.fc-button-inner { - position: relative; - float: left; - overflow: hidden; + +.fc-state-default.fc-corner-left { /* non-theme */ + border-top-left-radius: 4px; + border-bottom-left-radius: 4px; } - -.fc-state-default .fc-button-inner { /* non-theme */ - border-style: solid; - border-width: 0 1px; + +.fc-state-default.fc-corner-right { /* non-theme */ + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; } - -.fc-button-content { - position: relative; - float: left; - height: 1.9em; - line-height: 1.9em; - padding: 0 .6em; - white-space: nowrap; + +/* + Our default prev/next buttons use HTML entities like ‹ › « » + and we'll try to make them look good cross-browser. +*/ + +.fc-text-arrow { + margin: 0 .1em; + font-size: 2em; + font-family: "Courier New", Courier, monospace; + vertical-align: baseline; /* for IE7 */ + } + +.fc-button-prev .fc-text-arrow, +.fc-button-next .fc-text-arrow { /* for ‹ › */ + font-weight: bold; } /* icon (for jquery ui) */ -.fc-button-content .fc-icon-wrap { +.fc-button .fc-icon-wrap { position: relative; float: left; top: 50%; } -.fc-button-content .ui-icon { +.fc-button .ui-icon { position: relative; float: left; margin-top: -50%; @@ -189,107 +193,98 @@ html .fc, *top: -50%; } -/* gloss effect */ - -.fc-state-default .fc-button-effect { - position: absolute; - top: 50%; - left: 0; +/* + button states + borrowed from twitter bootstrap (http://twitter.github.com/bootstrap/) +*/ + +.fc-state-default { + background-color: #f5f5f5; + background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6)); + background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6); + background-image: -o-linear-gradient(top, #ffffff, #e6e6e6); + background-image: linear-gradient(to bottom, #ffffff, #e6e6e6); + background-repeat: repeat-x; + border-color: #e6e6e6 #e6e6e6 #bfbfbf; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + color: #333; + text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75); + box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); } - -.fc-state-default .fc-button-effect span { - position: absolute; - top: -100px; - left: 0; - width: 500px; - height: 100px; - border-width: 100px 0 0 1px; - border-style: solid; - border-color: #fff; - background: #444; - opacity: .09; - filter: alpha(opacity=9); - } - -/* button states (determines colors) */ - -.fc-state-default, -.fc-state-default .fc-button-inner { - border-style: solid; - border-color: #ccc #bbb #aaa; - background: #F3F3F3; - color: #000; - } - + .fc-state-hover, -.fc-state-hover .fc-button-inner { - border-color: #999; - } - .fc-state-down, -.fc-state-down .fc-button-inner { - border-color: #555; - background: #777; - } - .fc-state-active, -.fc-state-active .fc-button-inner { - border-color: #555; - background: #777; - color: #fff; +.fc-state-disabled { + color: #333333; + background-color: #e6e6e6; } - -.fc-state-disabled, -.fc-state-disabled .fc-button-inner { - color: #999; - border-color: #ddd; + +.fc-state-hover { + color: #333333; + text-decoration: none; + background-position: 0 -15px; + -webkit-transition: background-position 0.1s linear; + -moz-transition: background-position 0.1s linear; + -o-transition: background-position 0.1s linear; + transition: background-position 0.1s linear; } - + +.fc-state-down, +.fc-state-active { + background-color: #cccccc; + background-image: none; + outline: 0; + box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); + } + .fc-state-disabled { cursor: default; + background-image: none; + opacity: 0.65; + filter: alpha(opacity=65); + box-shadow: none; } - -.fc-state-disabled .fc-button-effect { - display: none; - } - + /* Global Event Styles ------------------------------------------------------------------------*/ + +.fc-event-container > * { + z-index: 8; + } + +.fc-event-container > .ui-draggable-dragging, +.fc-event-container > .ui-resizable-resizing { + z-index: 9; + } .fc-event { - border-style: solid; - border-width: 0; + border: 1px solid #3a87ad; /* default BORDER color */ + background-color: #3a87ad; /* default BACKGROUND color */ + color: #fff; /* default TEXT color */ font-size: .85em; cursor: default; } + +a.fc-event { + text-decoration: none; + } a.fc-event, .fc-event-draggable { cursor: pointer; } -a.fc-event { - text-decoration: none; - } - .fc-rtl .fc-event { text-align: right; } - -.fc-event-skin { - border-color: #36c; /* default BORDER color */ - background-color: #36c; /* default BACKGROUND color */ - color: #fff; /* default TEXT color */ - } - + .fc-event-inner { - position: relative; width: 100%; height: 100%; - border-style: solid; - border-width: 0; overflow: hidden; } @@ -298,7 +293,7 @@ a.fc-event { padding: 0 1px; } -.fc .ui-resizable-handle { /*** TODO: don't use ui-resizable anymore, change class ***/ +.fc .ui-resizable-handle { display: block; position: absolute; z-index: 99999; @@ -316,6 +311,20 @@ a.fc-event { border-width: 1px 0; margin-bottom: 1px; } + +.fc-ltr .fc-event-hori.fc-event-start, +.fc-rtl .fc-event-hori.fc-event-end { + border-left-width: 1px; + border-top-left-radius: 3px; + border-bottom-left-radius: 3px; + } + +.fc-ltr .fc-event-hori.fc-event-end, +.fc-rtl .fc-event-hori.fc-event-start { + border-right-width: 1px; + border-top-right-radius: 3px; + border-bottom-right-radius: 3px; + } /* resizable */ @@ -341,66 +350,6 @@ a.fc-event { -/* Fake Rounded Corners (for buttons and events) -------------------------------------------------------------*/ - -.fc-corner-left { - margin-left: 1px; - } - -.fc-corner-left .fc-button-inner, -.fc-corner-left .fc-event-inner { - margin-left: -1px; - } - -.fc-corner-right { - margin-right: 1px; - } - -.fc-corner-right .fc-button-inner, -.fc-corner-right .fc-event-inner { - margin-right: -1px; - } - -.fc-corner-top { - margin-top: 1px; - } - -.fc-corner-top .fc-event-inner { - margin-top: -1px; - } - -.fc-corner-bottom { - margin-bottom: 1px; - } - -.fc-corner-bottom .fc-event-inner { - margin-bottom: -1px; - } - - - -/* Fake Rounded Corners SPECIFICALLY FOR EVENTS ------------------------------------------------------------------*/ - -.fc-corner-left .fc-event-inner { - border-left-width: 1px; - } - -.fc-corner-right .fc-event-inner { - border-right-width: 1px; - } - -.fc-corner-top .fc-event-inner { - border-top-width: 1px; - } - -.fc-corner-bottom .fc-event-inner { - border-bottom-width: 1px; - } - - - /* Reusable Separate-border Table ------------------------------------------------------------*/ @@ -436,6 +385,15 @@ table.fc-border-separate { .fc-grid th { text-align: center; } + +.fc .fc-week-number { + width: 22px; + text-align: center; + } + +.fc .fc-week-number div { + padding: 0 2px; + } .fc-grid .fc-day-number { float: right; @@ -492,6 +450,10 @@ table.fc-border-separate { white-space: nowrap; font-weight: normal; } + +.fc-agenda .fc-week-number { + font-weight: bold; + } .fc-agenda .fc-day-content { padding: 2px 2px 1px; @@ -566,19 +528,28 @@ table.fc-border-separate { .fc-event-vert { border-width: 0 1px; } - -.fc-event-vert .fc-event-head, -.fc-event-vert .fc-event-content { - position: relative; - z-index: 2; - width: 100%; - overflow: hidden; + +.fc-event-vert.fc-event-start { + border-top-width: 1px; + border-top-left-radius: 3px; + border-top-right-radius: 3px; + } + +.fc-event-vert.fc-event-end { + border-bottom-width: 1px; + border-bottom-left-radius: 3px; + border-bottom-right-radius: 3px; } .fc-event-vert .fc-event-time { white-space: nowrap; font-size: 10px; } + +.fc-event-vert .fc-event-inner { + position: relative; + z-index: 2; + } .fc-event-vert .fc-event-bg { /* makes the event lighter w/ a semi-transparent overlay */ position: absolute; @@ -588,8 +559,8 @@ table.fc-border-separate { width: 100%; height: 100%; background: #fff; - opacity: .3; - filter: alpha(opacity=30); + opacity: .25; + filter: alpha(opacity=25); } .fc .ui-draggable-dragging .fc-event-bg, /* TODO: something nicer like .fc-opacity */ diff --git a/library/fullcalendar/fullcalendar.js b/library/fullcalendar/fullcalendar.js index 779a313c76..41c50856cf 100644 --- a/library/fullcalendar/fullcalendar.js +++ b/library/fullcalendar/fullcalendar.js @@ -1,23 +1,20 @@ -/** - * @preserve - * FullCalendar v1.5.3 - * http://arshaw.com/fullcalendar/ - * +/*! + * FullCalendar v1.6.4 + * Docs & License: http://arshaw.com/fullcalendar/ + * (c) 2013 Adam Shaw + */ + +/* * Use fullcalendar.css for basic styling. * For event drag & drop, requires jQuery UI draggable. * For event resizing, requires jQuery UI resizable. - * - * Copyright (c) 2011 Adam Shaw - * Dual licensed under the MIT and GPL licenses, located in - * MIT-LICENSE.txt and GPL-LICENSE.txt respectively. - * - * Date: Mon Feb 6 22:40:40 2012 -0800 - * */ (function($, undefined) { +;; + var defaults = { // display @@ -29,6 +26,9 @@ var defaults = { right: 'today prev,next' }, weekends: true, + weekNumbers: false, + weekNumberCalculation: 'iso', + weekNumberTitle: 'W', // editing //editable: false, @@ -66,10 +66,10 @@ var defaults = { dayNames: ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'], dayNamesShort: ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'], buttonText: { - prev: ' ◄ ', - next: ' ► ', - prevYear: ' << ', - nextYear: ' >> ', + prev: "", + next: "", + prevYear: "«", + nextYear: "»", today: 'today', month: 'month', week: 'week', @@ -86,7 +86,9 @@ var defaults = { //selectable: false, unselectAuto: true, - dropAccept: '*' + dropAccept: '*', + + handleWindowResize: true }; @@ -98,10 +100,10 @@ var rtlDefaults = { right: 'title' }, buttonText: { - prev: ' ► ', - next: ' ◄ ', - prevYear: ' >> ', - nextYear: ' << ' + prev: "", + next: "", + prevYear: "»", + nextYear: "«" }, buttonIcons: { prev: 'circle-triangle-e', @@ -111,7 +113,9 @@ var rtlDefaults = { -var fc = $.fullCalendar = { version: "1.5.3" }; +;; + +var fc = $.fullCalendar = { version: "1.6.4" }; var fcViews = fc.views = {}; @@ -139,7 +143,8 @@ $.fn.fullCalendar = function(options) { } return this; } - + + options = options || {}; // would like to have this logic in EventManager, but needs to happen before options are recursively extended var eventSources = options.eventSources || []; @@ -177,6 +182,8 @@ function setDefaults(d) { +;; + function Calendar(element, options, eventSources) { var t = this; @@ -221,10 +228,8 @@ function Calendar(element, options, eventSources) { var content; var tm; // for making theme classes var currentView; - var viewInstances = {}; var elementOuterWidth; var suggestedViewHeight; - var absoluteViewElement; var resizeUID = 0; var ignoreWindowResize = 0; var date = new Date(); @@ -243,11 +248,11 @@ function Calendar(element, options, eventSources) { function render(inc) { if (!content) { initialRender(); - }else{ + } + else if (elementVisible()) { + // mainly for the public API calcSize(); - markSizesDirty(); - markEventsDirty(); - renderView(inc); + _renderView(inc); } } @@ -258,18 +263,28 @@ function Calendar(element, options, eventSources) { if (options.isRTL) { element.addClass('fc-rtl'); } + else { + element.addClass('fc-ltr'); + } if (options.theme) { element.addClass('ui-widget'); } + content = $("
") .prependTo(element); + header = new Header(t, options); headerElement = header.render(); if (headerElement) { element.prepend(headerElement); } + changeView(options.defaultView); - $(window).resize(windowResize); + + if (options.handleWindowResize) { + $(window).resize(windowResize); + } + // needed for IE in a 0x0 iframe, b/c when it is resized, never triggers a windowResize if (!bodyVisible()) { lateRender(); @@ -289,21 +304,27 @@ function Calendar(element, options, eventSources) { function destroy() { + + if (currentView) { + trigger('viewDestroy', currentView, currentView, currentView.element); + currentView.triggerEventDestroy(); + } + $(window).unbind('resize', windowResize); + header.destroy(); content.remove(); element.removeClass('fc fc-rtl ui-widget'); } - function elementVisible() { - return _element.offsetWidth !== 0; + return element.is(':visible'); } function bodyVisible() { - return $('body')[0].offsetWidth !== 0; + return $('body').is(':visible'); } @@ -311,133 +332,97 @@ function Calendar(element, options, eventSources) { /* View Rendering -----------------------------------------------------------------------------*/ - // TODO: improve view switching (still weird transition in IE, and FF has whiteout problem) - + function changeView(newViewName) { if (!currentView || newViewName != currentView.name) { - ignoreWindowResize++; // because setMinHeight might change the height before render (and subsequently setSize) is reached - - unselect(); - - var oldView = currentView; - var newViewElement; - - if (oldView) { - (oldView.beforeHide || noop)(); // called before changing min-height. if called after, scroll state is reset (in Opera) - setMinHeight(content, content.height()); - oldView.element.hide(); - }else{ - setMinHeight(content, 1); // needs to be 1 (not 0) for IE7, or else view dimensions miscalculated - } - content.css('overflow', 'hidden'); - - currentView = viewInstances[newViewName]; - if (currentView) { - currentView.element.show(); - }else{ - currentView = viewInstances[newViewName] = new fcViews[newViewName]( - newViewElement = absoluteViewElement = - $("
") - .appendTo(content), - t // the calendar object - ); - } - - if (oldView) { - header.deactivateButton(oldView.name); - } - header.activateButton(newViewName); - - renderView(); // after height has been set, will make absoluteViewElement's position=relative, then set to null - - content.css('overflow', ''); - if (oldView) { - setMinHeight(content, 1); - } - - if (!newViewElement) { - (currentView.afterShow || noop)(); // called after setting min-height/overflow, so in final scroll state (for Opera) - } - - ignoreWindowResize--; + _changeView(newViewName); } } - - - + + + function _changeView(newViewName) { + ignoreWindowResize++; + + if (currentView) { + trigger('viewDestroy', currentView, currentView, currentView.element); + unselect(); + currentView.triggerEventDestroy(); // trigger 'eventDestroy' for each event + freezeContentHeight(); + currentView.element.remove(); + header.deactivateButton(currentView.name); + } + + header.activateButton(newViewName); + + currentView = new fcViews[newViewName]( + $("
") + .appendTo(content), + t // the calendar object + ); + + renderView(); + unfreezeContentHeight(); + + ignoreWindowResize--; + } + + function renderView(inc) { - if (elementVisible()) { - ignoreWindowResize++; // because renderEvents might temporarily change the height before setSize is reached - - unselect(); - - if (suggestedViewHeight === undefined) { - calcSize(); + if ( + !currentView.start || // never rendered before + inc || date < currentView.start || date >= currentView.end // or new date range + ) { + if (elementVisible()) { + _renderView(inc); } - - var forceEventRender = false; - if (!currentView.start || inc || date < currentView.start || date >= currentView.end) { - // view must render an entire new date range (and refetch/render events) - currentView.render(date, inc || 0); // responsible for clearing events - setSize(true); - forceEventRender = true; - } - else if (currentView.sizeDirty) { - // view must resize (and rerender events) - currentView.clearEvents(); - setSize(); - forceEventRender = true; - } - else if (currentView.eventsDirty) { - currentView.clearEvents(); - forceEventRender = true; - } - currentView.sizeDirty = false; - currentView.eventsDirty = false; - updateEvents(forceEventRender); - - elementOuterWidth = element.outerWidth(); - - header.updateTitle(currentView.title); - var today = new Date(); - if (today >= currentView.start && today < currentView.end) { - header.disableButton('today'); - }else{ - header.enableButton('today'); - } - - ignoreWindowResize--; - currentView.trigger('viewDisplay', _element); } } + + + function _renderView(inc) { // assumes elementVisible + ignoreWindowResize++; + + if (currentView.start) { // already been rendered? + trigger('viewDestroy', currentView, currentView, currentView.element); + unselect(); + clearEvents(); + } + + freezeContentHeight(); + currentView.render(date, inc || 0); // the view's render method ONLY renders the skeleton, nothing else + setSize(); + unfreezeContentHeight(); + (currentView.afterRender || noop)(); + + updateTitle(); + updateTodayButton(); + + trigger('viewRender', currentView, currentView, currentView.element); + currentView.trigger('viewDisplay', _element); // deprecated + + ignoreWindowResize--; + + getAndRenderEvents(); + } - + /* Resizing -----------------------------------------------------------------------------*/ function updateSize() { - markSizesDirty(); if (elementVisible()) { + unselect(); + clearEvents(); calcSize(); setSize(); - unselect(); - currentView.clearEvents(); - currentView.renderEvents(events); - currentView.sizeDirty = false; + renderEvents(); } } - function markSizesDirty() { - $.each(viewInstances, function(i, inst) { - inst.sizeDirty = true; - }); - } - - - function calcSize() { + function calcSize() { // assumes elementVisible if (options.contentHeight) { suggestedViewHeight = options.contentHeight; } @@ -450,15 +435,20 @@ function Calendar(element, options, eventSources) { } - function setSize(dateChanged) { // todo: dateChanged? - ignoreWindowResize++; - currentView.setHeight(suggestedViewHeight, dateChanged); - if (absoluteViewElement) { - absoluteViewElement.css('position', 'relative'); - absoluteViewElement = null; + function setSize() { // assumes elementVisible + + if (suggestedViewHeight === undefined) { + calcSize(); // for first time + // NOTE: we don't want to recalculate on every renderView because + // it could result in oscillating heights due to scrollbars. } - currentView.setWidth(content.width(), dateChanged); + + ignoreWindowResize++; + currentView.setHeight(suggestedViewHeight); + currentView.setWidth(content.width()); ignoreWindowResize--; + + elementOuterWidth = element.outerWidth(); } @@ -487,52 +477,85 @@ function Calendar(element, options, eventSources) { /* Event Fetching/Rendering -----------------------------------------------------------------------------*/ + // TODO: going forward, most of this stuff should be directly handled by the view + + + function refetchEvents() { // can be called as an API method + clearEvents(); + fetchAndRenderEvents(); + } + + + function rerenderEvents(modifiedEventID) { // can be called as an API method + clearEvents(); + renderEvents(modifiedEventID); + } + + + function renderEvents(modifiedEventID) { // TODO: remove modifiedEventID hack + if (elementVisible()) { + currentView.setEventData(events); // for View.js, TODO: unify with renderEvents + currentView.renderEvents(events, modifiedEventID); // actually render the DOM elements + currentView.trigger('eventAfterAllRender'); + } + } + + + function clearEvents() { + currentView.triggerEventDestroy(); // trigger 'eventDestroy' for each event + currentView.clearEvents(); // actually remove the DOM elements + currentView.clearEventData(); // for View.js, TODO: unify with clearEvents + } - - // fetches events if necessary, rerenders events if necessary (or if forced) - function updateEvents(forceRender) { + + function getAndRenderEvents() { if (!options.lazyFetching || isFetchNeeded(currentView.visStart, currentView.visEnd)) { - refetchEvents(); + fetchAndRenderEvents(); } - else if (forceRender) { - rerenderEvents(); + else { + renderEvents(); } } - - - function refetchEvents() { - fetchEvents(currentView.visStart, currentView.visEnd); // will call reportEvents + + + function fetchAndRenderEvents() { + fetchEvents(currentView.visStart, currentView.visEnd); + // ... will call reportEvents + // ... which will call renderEvents } - + // called when event data arrives function reportEvents(_events) { events = _events; - rerenderEvents(); + renderEvents(); } - - + + // called when a single event's data has been changed function reportEventChange(eventID) { rerenderEvents(eventID); } - - - // attempts to rerenderEvents - function rerenderEvents(modifiedEventID) { - markEventsDirty(); - if (elementVisible()) { - currentView.clearEvents(); - currentView.renderEvents(events, modifiedEventID); - currentView.eventsDirty = false; - } + + + + /* Header Updating + -----------------------------------------------------------------------------*/ + + + function updateTitle() { + header.updateTitle(currentView.title); } - - - function markEventsDirty() { - $.each(viewInstances, function(i, inst) { - inst.eventsDirty = true; - }); + + + function updateTodayButton() { + var today = new Date(); + if (today >= currentView.start && today < currentView.end) { + header.disableButton('today'); + } + else { + header.enableButton('today'); + } } @@ -613,6 +636,29 @@ function Calendar(element, options, eventSources) { function getDate() { return cloneDate(date); } + + + + /* Height "Freezing" + -----------------------------------------------------------------------------*/ + + + function freezeContentHeight() { + content.css({ + width: '100%', + height: content.height(), + overflow: 'hidden' + }); + } + + + function unfreezeContentHeight() { + content.css({ + width: '', + height: '', + overflow: '' + }); + } @@ -674,6 +720,8 @@ function Calendar(element, options, eventSources) { } +;; + function Header(calendar, options) { var t = this; @@ -747,54 +795,47 @@ function Header(calendar, options) { var text = smartProperty(options.buttonText, buttonName); // why are we using smartProperty here? var button = $( "" + - "" + - "" + - (icon ? - "" + - "" + - "" : - text - ) + - "" + - "" + - "" + + (icon ? + "" + + "" + + "" : + text + ) + "" - ); - if (button) { - button - .click(function() { - if (!button.hasClass(tm + '-state-disabled')) { - buttonClick(); - } - }) - .mousedown(function() { + ) + .click(function() { + if (!button.hasClass(tm + '-state-disabled')) { + buttonClick(); + } + }) + .mousedown(function() { + button + .not('.' + tm + '-state-active') + .not('.' + tm + '-state-disabled') + .addClass(tm + '-state-down'); + }) + .mouseup(function() { + button.removeClass(tm + '-state-down'); + }) + .hover( + function() { button .not('.' + tm + '-state-active') .not('.' + tm + '-state-disabled') - .addClass(tm + '-state-down'); - }) - .mouseup(function() { - button.removeClass(tm + '-state-down'); - }) - .hover( - function() { - button - .not('.' + tm + '-state-active') - .not('.' + tm + '-state-disabled') - .addClass(tm + '-state-hover'); - }, - function() { - button - .removeClass(tm + '-state-hover') - .removeClass(tm + '-state-down'); - } - ) - .appendTo(e); - if (!prevButton) { - button.addClass(tm + '-corner-left'); - } - prevButton = button; + .addClass(tm + '-state-hover'); + }, + function() { + button + .removeClass(tm + '-state-hover') + .removeClass(tm + '-state-down'); + } + ) + .appendTo(e); + disableTextSelection(button); + if (!prevButton) { + button.addClass(tm + '-corner-left'); } + prevButton = button; } } }); @@ -839,6 +880,8 @@ function Header(calendar, options) { } +;; + fc.sourceNormalizers = []; fc.sourceFetchers = []; @@ -914,6 +957,16 @@ function EventManager(options, _sources) { _fetchEventSource(source, function(events) { if (fetchID == currentFetchID) { if (events) { + + if (options.eventDataTransform) { + events = $.map(events, options.eventDataTransform); + } + if (source.eventDataTransform) { + events = $.map(events, source.eventDataTransform); + } + // TODO: this technique is not ideal for static array event sources. + // For arrays, we'll want to process all events right in the beginning, then never again. + for (var i=0; i seg2.start && seg1.start < seg2.end; -} - - - -/* Event Sorting ------------------------------------------------------------------------------*/ - - -// event rendering utilities -function sliceSegs(events, visEventEnds, start, end) { - var segs = [], - i, len=events.length, event, - eventStart, eventEnd, - segStart, segEnd, - isStart, isEnd; - for (i=0; i start && eventStart < end) { - if (eventStart < start) { - segStart = cloneDate(start); - isStart = false; - }else{ - segStart = eventStart; - isStart = true; - } - if (eventEnd > end) { - segEnd = cloneDate(end); - isEnd = false; - }else{ - segEnd = eventEnd; - isEnd = true; - } - segs.push({ - event: event, - start: segStart, - end: segEnd, - isStart: isStart, - isEnd: isEnd, - msLength: segEnd - segStart - }); - } - } - return segs.sort(segCmp); -} - - -// event rendering calculation utilities -function stackSegs(segs) { - var levels = [], - i, len = segs.length, seg, - j, collide, k; - for (i=0; i" + - "" + - ""; - for (i=0; i"; // need fc- for setDayID - } - s += - "" + - "" + - ""; - for (i=0; i"; - for (j=0; j" + // need fc- for setDayID - "
" + - (showNumbers ? - "
" : - '' - ) + - "
" + - "
 
" + - "
" + - "
" + - ""; - } - s += - ""; - } - s += - "" + - ""; - table = $(s).appendTo(element); - - head = table.find('thead'); - headCells = head.find('th'); - body = table.find('tbody'); - bodyRows = body.find('tr'); - bodyCells = body.find('td'); - bodyFirstCells = bodyCells.filter(':first-child'); - bodyCellTopInners = bodyRows.eq(0).find('div.fc-day-content div'); - - markFirstLast(head.add(head.find('tr'))); // marks first+last tr/th's - markFirstLast(bodyRows); // marks first+last td's - bodyRows.eq(0).addClass('fc-first'); // fc-last is done in updateCells - - dayBind(bodyCells); - + function buildEventContainer() { daySegmentContainer = - $("
") + $("
") .appendTo(element); } - - function updateCells(firstTime) { - var dowDirty = firstTime || rowCnt == 1; // could the cells' day-of-weeks need updating? + function buildTable() { + var html = buildTableHTML(); + + if (table) { + table.remove(); + } + table = $(html).appendTo(element); + + head = table.find('thead'); + headCells = head.find('.fc-day-header'); + body = table.find('tbody'); + bodyRows = body.find('tr'); + bodyCells = body.find('.fc-day'); + bodyFirstCells = bodyRows.find('td:first-child'); + + firstRowCellInners = bodyRows.eq(0).find('.fc-day > div'); + firstRowCellContentInners = bodyRows.eq(0).find('.fc-day-content > div'); + + markFirstLast(head.add(head.find('tr'))); // marks first+last tr/th's + markFirstLast(bodyRows); // marks first+last td's + bodyRows.eq(0).addClass('fc-first'); + bodyRows.filter(':last').addClass('fc-last'); + + bodyCells.each(function(i, _cell) { + var date = cellToDate( + Math.floor(i / colCnt), + i % colCnt + ); + trigger('dayRender', t, date, $(_cell)); + }); + + dayBind(bodyCells); + } + + + + /* HTML Building + -----------------------------------------------------------*/ + + + function buildTableHTML() { + var html = + "" + + buildHeadHTML() + + buildBodyHTML() + + "
"; + + return html; + } + + + function buildHeadHTML() { + var headerClass = tm + "-widget-header"; + var html = ''; + var col; + var date; + + html += ""; + + if (showWeekNumbers) { + html += + "" + + htmlEscape(weekNumberTitle) + + ""; + } + + for (col=0; col" + + htmlEscape(formatDate(date, colFormat)) + + ""; + } + + html += ""; + + return html; + } + + + function buildBodyHTML() { + var contentClass = tm + "-widget-content"; + var html = ''; + var row; + var col; + var date; + + html += ""; + + for (row=0; row" + + "
" + + htmlEscape(formatDate(date, weekNumberFormat)) + + "
" + + ""; + } + + for (col=0; col" + + "
"; + + if (showNumbers) { + html += "
" + date.getDate() + "
"; + } + + html += + "
" + + "
 
" + + "
" + + "
" + + ""; + + return html; } - + + + + /* Dimensions + -----------------------------------------------------------*/ function setHeight(height) { @@ -2345,8 +2420,8 @@ function BasicView(element, calendar, viewName) { bodyFirstCells.each(function(i, _cell) { if (i < rowCnt) { cell = $(_cell); - setMinHeight( - cell.find('> div'), + cell.find('> div').css( + 'min-height', (i==rowCnt-1 ? rowHeightLast : rowHeight) - vsides(cell) ); } @@ -2357,8 +2432,15 @@ function BasicView(element, calendar, viewName) { function setWidth(width) { viewWidth = width; + colPositions.clear(); colContentPositions.clear(); - colWidth = Math.floor(viewWidth / colCnt); + + weekNumberWidth = 0; + if (showWeekNumbers) { + weekNumberWidth = head.find('th.fc-week-number').outerWidth(); + } + + colWidth = Math.floor((viewWidth - weekNumberWidth) / colCnt); setOuterWidth(headCells.slice(0, -1), colWidth); } @@ -2376,8 +2458,7 @@ function BasicView(element, calendar, viewName) { function dayClick(ev) { if (!opt('selectable')) { // if selectable, SelectionManager will worry about dayClick - var index = parseInt(this.className.match(/fc\-day(\d+)/)[1]); // TODO: maybe use .data - var date = indexDate(index); + var date = parseISO8601($(this).data('date')); trigger('dayClick', this, date, true, ev); } } @@ -2386,35 +2467,30 @@ function BasicView(element, calendar, viewName) { /* Semi-transparent Overlay Helpers ------------------------------------------------------*/ - - + // TODO: should be consolidated with AgendaView's methods + + function renderDayOverlay(overlayStart, overlayEnd, refreshCoordinateGrid) { // overlayEnd is exclusive + if (refreshCoordinateGrid) { coordinateGrid.build(); } - var rowStart = cloneDate(t.visStart); - var rowEnd = addDays(cloneDate(rowStart), colCnt); - for (var i=0; i" + - "" + - "" + - " "; - for (i=0; i"; // fc- needed for setDayID - } - s += - " " + - "" + - "" + - "" + - "" + - " "; - for (i=0; i" + // fc- needed for setDayID - "
" + - "
" + - "
 
" + - "
" + - "
" + - ""; - } - s += - " " + - "" + - "" + - ""; - dayTable = $(s).appendTo(element); - dayHead = dayTable.find('thead'); - dayHeadCells = dayHead.find('th').slice(1, -1); - dayBody = dayTable.find('tbody'); - dayBodyCells = dayBody.find('td').slice(0, -1); - dayBodyCellInners = dayBodyCells.find('div.fc-day-content div'); - dayBodyFirstCell = dayBodyCells.eq(0); - dayBodyFirstCellStretcher = dayBodyFirstCell.find('> div'); - - markFirstLast(dayHead.add(dayHead.find('tr'))); - markFirstLast(dayBody.add(dayBody.find('tr'))); - - axisFirstCells = dayHead.find('th:first'); - gutterCells = dayTable.find('.fc-agenda-gutter'); + buildDayTable(); slotLayer = $("
") @@ -3026,7 +2947,7 @@ function AgendaView(element, calendar, viewName) { if (opt('allDaySlot')) { daySegmentContainer = - $("
") + $("
") .appendTo(slotLayer); s = @@ -3044,9 +2965,6 @@ function AgendaView(element, calendar, viewName) { dayBind(allDayRow.find('td')); - axisFirstCells = axisFirstCells.add(allDayTable.find('th:first')); - gutterCells = gutterCells.add(allDayTable.find('th.fc-agenda-gutter')); - slotLayer.append( "
" + "
" + @@ -3063,13 +2981,13 @@ function AgendaView(element, calendar, viewName) { $("
") .appendTo(slotLayer); - slotContent = + slotContainer = $("
") .appendTo(slotScroller); slotSegmentContainer = - $("
") - .appendTo(slotContent); + $("
") + .appendTo(slotContainer); s = "" + @@ -3095,39 +3013,170 @@ function AgendaView(element, calendar, viewName) { s += "" + "
"; - slotTable = $(s).appendTo(slotContent); - slotTableFirstInner = slotTable.find('div:first'); + slotTable = $(s).appendTo(slotContainer); slotBind(slotTable.find('td')); - - axisFirstCells = axisFirstCells.add(slotTable.find('th:first')); } - - - - function updateCells() { - var i; - var headCell; - var bodyCell; + + + + /* Build Day Table + -----------------------------------------------------------------------*/ + + + function buildDayTable() { + var html = buildDayTableHTML(); + + if (dayTable) { + dayTable.remove(); + } + dayTable = $(html).appendTo(element); + + dayHead = dayTable.find('thead'); + dayHeadCells = dayHead.find('th').slice(1, -1); // exclude gutter + dayBody = dayTable.find('tbody'); + dayBodyCells = dayBody.find('td').slice(0, -1); // exclude gutter + dayBodyCellInners = dayBodyCells.find('> div'); + dayBodyCellContentInners = dayBodyCells.find('.fc-day-content > div'); + + dayBodyFirstCell = dayBodyCells.eq(0); + dayBodyFirstCellStretcher = dayBodyCellInners.eq(0); + + markFirstLast(dayHead.add(dayHead.find('tr'))); + markFirstLast(dayBody.add(dayBody.find('tr'))); + + // TODO: now that we rebuild the cells every time, we should call dayRender + } + + + function buildDayTableHTML() { + var html = + "" + + buildDayTableHeadHTML() + + buildDayTableBodyHTML() + + "
"; + + return html; + } + + + function buildDayTableHeadHTML() { + var headerClass = tm + "-widget-header"; + var date; + var html = ''; + var weekText; + var col; + + html += + "" + + ""; + + if (showWeekNumbers) { + date = cellToDate(0, 0); + weekText = formatDate(date, weekNumberFormat); + if (rtl) { + weekText += weekNumberTitle; + } + else { + weekText = weekNumberTitle + weekText; + } + html += + "" + + htmlEscape(weekText) + + ""; + } + else { + html += " "; + } + + for (col=0; col" + + htmlEscape(formatDate(date, colFormat)) + + ""; + } + + html += + " " + + "" + + ""; + + return html; + } + + + function buildDayTableBodyHTML() { + var headerClass = tm + "-widget-header"; // TODO: make these when updateOptions() called + var contentClass = tm + "-widget-content"; var date; var today = clearTime(new Date()); - for (i=0; i" + + "" + + " "; + + cellsHTML = ''; + + for (col=0; col" + + "
" + + "
" + + "
 
" + + "
" + + "
" + + ""; + + cellsHTML += cellHTML; } + + html += cellsHTML; + html += + " " + + "" + + ""; + + return html; } + + + // TODO: data-date on the cells + + /* Dimensions + -----------------------------------------------------------------------*/ + - function setHeight(height, dateChanged) { + function setHeight(height) { if (height === undefined) { height = viewHeight; } @@ -3140,7 +3189,7 @@ function AgendaView(element, calendar, viewName) { height - headHeight, // when scrollbars slotTable.height() + allDayHeight + 1 // when no scrollbars. +1 for bottom border ); - + dayBodyFirstCellStretcher .height(bodyHeight - vsides(dayBodyFirstCell)); @@ -3148,18 +3197,25 @@ function AgendaView(element, calendar, viewName) { slotScroller.height(bodyHeight - allDayHeight - 1); - slotHeight = slotTableFirstInner.height() + 1; // +1 for border - - if (dateChanged) { - resetScroll(); - } + // the stylesheet guarantees that the first row has no border. + // this allows .height() to work well cross-browser. + slotHeight = slotTable.find('tr:first').height() + 1; // +1 for bottom border + + snapRatio = opt('slotMinutes') / snapMinutes; + snapHeight = slotHeight / snapRatio; } - function setWidth(width) { viewWidth = width; + colPositions.clear(); colContentPositions.clear(); + + var axisFirstCells = dayHead.find('th:first'); + if (allDayTable) { + axisFirstCells = axisFirstCells.add(allDayTable.find('th:first')); + } + axisFirstCells = axisFirstCells.add(slotTable.find('th:first')); axisWidth = 0; setOuterWidth( @@ -3171,8 +3227,12 @@ function AgendaView(element, calendar, viewName) { axisWidth ); + var gutterCells = dayTable.find('.fc-agenda-gutter'); + if (allDayTable) { + gutterCells = gutterCells.add(allDayTable.find('th.fc-agenda-gutter')); + } + var slotTableWidth = slotScroller[0].clientWidth; // needs to be done after axisWidth (for IE7) - //slotTable.width(slotTableWidth); gutterWidth = slotScroller.width() - slotTableWidth; if (gutterWidth) { @@ -3194,6 +3254,10 @@ function AgendaView(element, calendar, viewName) { + /* Scrolling + -----------------------------------------------------------------------*/ + + function resetScroll() { var d0 = zeroDate(); var scrollDate = cloneDate(d0); @@ -3205,15 +3269,10 @@ function AgendaView(element, calendar, viewName) { scroll(); setTimeout(scroll, 0); // overrides any previous scroll state made by the browser } - - - function beforeHide() { - savedScrollTop = slotScroller.scrollTop(); - } - - - function afterShow() { - slotScroller.scrollTop(savedScrollTop); + + + function afterRender() { // after the view has been freshly rendered and sized + resetScroll(); } @@ -3237,7 +3296,7 @@ function AgendaView(element, calendar, viewName) { function slotClick(ev) { if (!opt('selectable')) { // if selectable, SelectionManager will worry about dayClick var col = Math.min(colCnt-1, Math.floor((ev.pageX - dayTable.offset().left - axisWidth) / colWidth)); - var date = colDate(col); + var date = cellToDate(0, col); var rowMatch = this.parentNode.className.match(/fc-slot(\d+)/); // TODO: maybe use data if (rowMatch) { var mins = parseInt(rowMatch[1]) * opt('slotMinutes'); @@ -3255,26 +3314,26 @@ function AgendaView(element, calendar, viewName) { /* Semi-transparent Overlay Helpers -----------------------------------------------------*/ - + // TODO: should be consolidated with BasicView's methods + + + function renderDayOverlay(overlayStart, overlayEnd, refreshCoordinateGrid) { // overlayEnd is exclusive - function renderDayOverlay(startDate, endDate, refreshCoordinateGrid) { // endDate is exclusive if (refreshCoordinateGrid) { coordinateGrid.build(); } - var visStart = cloneDate(t.visStart); - var startCol, endCol; - if (rtl) { - startCol = dayDiff(endDate, visStart)*dis+dit+1; - endCol = dayDiff(startDate, visStart)*dis+dit+1; - }else{ - startCol = dayDiff(startDate, visStart); - endCol = dayDiff(endDate, visStart); - } - startCol = Math.max(0, startCol); - endCol = Math.min(colCnt, endCol); - if (startCol < endCol) { + + var segments = rangeToSegments(overlayStart, overlayEnd); + + for (var i=0; i= 0) { - addMinutes(d, minMinute + slotIndex * opt('slotMinutes')); + addMinutes(d, minMinute + slotIndex * snapMinutes); } return d; } - function colDate(col) { // returns dates with 00:00:00 - return addDays(cloneDate(t.visStart), col*dis+dit); - } - - - function cellIsAllDay(cell) { - return opt('allDaySlot') && !cell.row; - } - - - function dayOfWeekCol(dayOfWeek) { - return ((dayOfWeek - Math.max(firstDay, nwe) + colCnt) % colCnt)*dis+dit; - } - - - - // get the Y coordinate of the given time on the given day (both Date objects) function timePosition(day, time) { // both date objects. day holds 00:00 of current day day = cloneDate(day, true); @@ -3418,7 +3465,11 @@ function AgendaView(element, calendar, viewName) { slotI = Math.floor(minutes / slotMinutes), slotTop = slotTopCache[slotI]; if (slotTop === undefined) { - slotTop = slotTopCache[slotI] = slotTable.find('tr:eq(' + slotI + ') td div')[0].offsetTop; //.position().top; // need this optimization??? + slotTop = slotTopCache[slotI] = + slotTable.find('tr').eq(slotI).find('td div')[0].offsetTop; + // .eq() is faster than ":eq()" selector + // [0].offsetTop is faster than .position().top (do we really need this optimization?) + // a better optimization would be to cache all these divs } return Math.max(0, Math.round( slotTop - 1 + slotHeight * ((minutes % slotMinutes) / slotMinutes) @@ -3426,14 +3477,6 @@ function AgendaView(element, calendar, viewName) { } - function allDayBounds() { - return { - left: axisWidth, - right: viewWidth - gutterWidth - } - } - - function getAllDayRow(index) { return allDayRow; } @@ -3476,9 +3519,9 @@ function AgendaView(element, calendar, viewName) { var helperOption = opt('selectHelper'); coordinateGrid.build(); if (helperOption) { - var col = dayDiff(startDate, t.visStart) * dis + dit; + var col = dateToCell(startDate).col; if (col >= 0 && col < colCnt) { // only works when times are on same day - var rect = coordinateGrid.rect(0, col, 0, col, slotContent); // only for horizontal coords + var rect = coordinateGrid.rect(0, col, 0, col, slotContainer); // only for horizontal coords var top = timePosition(startDate, startDate); var bottom = timePosition(startDate, endDate); if (bottom > top) { // protect against selections that are entirely before or after visible range @@ -3490,10 +3533,9 @@ function AgendaView(element, calendar, viewName) { var helperRes = helperOption(startDate, endDate); if (helperRes) { rect.position = 'absolute'; - rect.zIndex = 8; selectionHelper = $(helperRes) .css(rect) - .appendTo(slotContent); + .appendTo(slotContainer); } }else{ rect.isStart = true; // conside rect a "seg" now @@ -3512,7 +3554,7 @@ function AgendaView(element, calendar, viewName) { } if (selectionHelper) { slotBind(selectionHelper); - slotContent.append(selectionHelper); + slotContainer.append(selectionHelper); setOuterWidth(selectionHelper, rect.width, true); // needs to be after appended setOuterHeight(selectionHelper, rect.height, true); } @@ -3539,15 +3581,15 @@ function AgendaView(element, calendar, viewName) { var dates; hoverListener.start(function(cell, origCell) { clearSelection(); - if (cell && cell.col == origCell.col && !cellIsAllDay(cell)) { - var d1 = cellDate(origCell); - var d2 = cellDate(cell); + if (cell && cell.col == origCell.col && !getIsCellAllDay(cell)) { + var d1 = realCellToDate(origCell); + var d2 = realCellToDate(cell); dates = [ d1, - addMinutes(cloneDate(d1), opt('slotMinutes')), + addMinutes(cloneDate(d1), snapMinutes), // calculate minutes depending on selection slot minutes d2, - addMinutes(cloneDate(d2), opt('slotMinutes')) - ].sort(cmp); + addMinutes(cloneDate(d2), snapMinutes) + ].sort(dateCompare); renderSlotSelection(dates[0], dates[3]); }else{ dates = null; @@ -3564,10 +3606,10 @@ function AgendaView(element, calendar, viewName) { }); } } - - + + function reportDayClick(date, allDay, ev) { - trigger('dayClick', dayBodyCells[dayOfWeekCol(date.getDay())], date, allDay, ev); + trigger('dayClick', dayBodyCells[dateToCell(date).col], date, allDay, ev); } @@ -3580,10 +3622,10 @@ function AgendaView(element, calendar, viewName) { hoverListener.start(function(cell) { clearOverlays(); if (cell) { - if (cellIsAllDay(cell)) { + if (getIsCellAllDay(cell)) { renderCellOverlay(cell.row, cell.col, cell.row, cell.col); }else{ - var d1 = cellDate(cell); + var d1 = realCellToDate(cell); var d2 = addMinutes(cloneDate(d1), opt('defaultEventMinutes')); renderSlotOverlay(d1, d2); } @@ -3596,35 +3638,32 @@ function AgendaView(element, calendar, viewName) { var cell = hoverListener.stop(); clearOverlays(); if (cell) { - trigger('drop', _dragElement, cellDate(cell), cellIsAllDay(cell), ev, ui); + trigger('drop', _dragElement, realCellToDate(cell), getIsCellAllDay(cell), ev, ui); } } - + } +;; + function AgendaEventRenderer() { var t = this; // exports t.renderEvents = renderEvents; - t.compileDaySegs = compileDaySegs; // for DayEventRenderer t.clearEvents = clearEvents; t.slotSegHtml = slotSegHtml; - t.bindDaySeg = bindDaySeg; // imports DayEventRenderer.call(t); var opt = t.opt; var trigger = t.trigger; - //var setOverflowHidden = t.setOverflowHidden; var isEventDraggable = t.isEventDraggable; var isEventResizable = t.isEventResizable; var eventEnd = t.eventEnd; - var reportEvents = t.reportEvents; - var reportEventClear = t.reportEventClear; var eventElementHandlers = t.eventElementHandlers; var setHeight = t.setHeight; var getDaySegmentContainer = t.getDaySegmentContainer; @@ -3633,14 +3672,15 @@ function AgendaEventRenderer() { var getMaxMinute = t.getMaxMinute; var getMinMinute = t.getMinMinute; var timePosition = t.timePosition; + var getIsCellAllDay = t.getIsCellAllDay; var colContentLeft = t.colContentLeft; var colContentRight = t.colContentRight; - var renderDaySegs = t.renderDaySegs; - var resizableDayEvent = t.resizableDayEvent; // TODO: streamline binding architecture + var cellToDate = t.cellToDate; var getColCnt = t.getColCnt; var getColWidth = t.getColWidth; - var getSlotHeight = t.getSlotHeight; - var getBodyContent = t.getBodyContent; + var getSnapHeight = t.getSnapHeight; + var getSnapMinutes = t.getSnapMinutes; + var getSlotContainer = t.getSlotContainer; var reportEventElement = t.reportEventElement; var showEvents = t.showEvents; var hideEvents = t.hideEvents; @@ -3648,10 +3688,15 @@ function AgendaEventRenderer() { var eventResize = t.eventResize; var renderDayOverlay = t.renderDayOverlay; var clearOverlays = t.clearOverlays; + var renderDayEvents = t.renderDayEvents; var calendar = t.calendar; var formatDate = calendar.formatDate; var formatDates = calendar.formatDates; - + + + // overrides + t.draggableDayEvent = draggableDayEvent; + /* Rendering @@ -3659,7 +3704,6 @@ function AgendaEventRenderer() { function renderEvents(events, modifiedEventId) { - reportEvents(events); var i, len=events.length, dayEvents=[], slotEvents=[]; @@ -3670,67 +3714,96 @@ function AgendaEventRenderer() { slotEvents.push(events[i]); } } + if (opt('allDaySlot')) { - renderDaySegs(compileDaySegs(dayEvents), modifiedEventId); + renderDayEvents(dayEvents, modifiedEventId); setHeight(); // no params means set to viewHeight } + renderSlotSegs(compileSlotSegs(slotEvents), modifiedEventId); } function clearEvents() { - reportEventClear(); getDaySegmentContainer().empty(); getSlotSegmentContainer().empty(); } - - - function compileDaySegs(events) { - var levels = stackSegs(sliceSegs(events, $.map(events, exclEndDay), t.visStart, t.visEnd)), - i, levelCnt=levels.length, level, - j, seg, - segs=[]; - for (i=0; i start && eventStart < end) { + if (eventStart < start) { + segStart = cloneDate(start); + isStart = false; + }else{ + segStart = eventStart; + isStart = true; + } + if (eventEnd > end) { + segEnd = cloneDate(end); + isEnd = false; + }else{ + segEnd = eventEnd; + isEnd = true; + } + segs.push({ + event: event, + start: segStart, + end: segEnd, + isStart: isStart, + isEnd: isEnd + }); + } + } + return segs.sort(compareSlotSegs); + } + + function slotEventEnd(event) { if (event.end) { return cloneDate(event.end); @@ -3741,38 +3814,29 @@ function AgendaEventRenderer() { // renders events in the 'time slots' at the bottom + // TODO: when we refactor this, when user returns `false` eventRender, don't have empty space + // TODO: refactor will include using pixels to detect collisions instead of dates (handy for seg cmp) function renderSlotSegs(segs, modifiedEventId) { var i, segCnt=segs.length, seg, event, - classes, - top, bottom, - colI, levelI, forward, - leftmost, - availWidth, - outerWidth, + top, + bottom, + columnLeft, + columnRight, + columnWidth, + width, left, - html='', + right, + html = '', eventElements, eventElement, triggerRes, - vsideCache={}, - hsideCache={}, - key, val, - contentElement, + titleElement, height, slotSegmentContainer = getSlotSegmentContainer(), - rtl, dis, dit, - colCnt = getColCnt(); - - if (rtl = opt('isRTL')) { - dis = -1; - dit = colCnt - 1; - }else{ - dis = 1; - dit = 0; - } + isRTL = opt('isRTL'); // calculate position/dimensions, create html for (i=0; i" + - "
" + - "
" + + "
" + "
" + htmlEscape(formatDates(event.start, event.end, opt('timeFormat'))) + "
" + - "
" + - "
" + "
" + - htmlEscape(event.title) + + htmlEscape(event.title || '') + "
" + "
" + - "
" + - "
"; // close inner + "
"; if (seg.isEnd && isEventResizable(event)) { html += "
=
"; @@ -3929,18 +4007,6 @@ function AgendaEventRenderer() { } - function bindDaySeg(event, eventElement, seg) { - if (isEventDraggable(event)) { - draggableDayEvent(event, eventElement, seg.isStart); - } - if (seg.isEnd && isEventResizable(event)) { - resizableDayEvent(event, eventElement, seg); - } - eventElementHandlers(event, eventElement); - // needs to be after, because resizableDayEvent might stopImmediatePropagation on click - } - - function bindSlotSeg(event, eventElement, seg) { var timeElement = eventElement.find('div.fc-event-time'); if (isEventDraggable(event)) { @@ -3959,31 +4025,34 @@ function AgendaEventRenderer() { // when event starts out FULL-DAY + // overrides DayEventRenderer's version because it needs to account for dragging elements + // to and from the slot area. - function draggableDayEvent(event, eventElement, isStart) { + function draggableDayEvent(event, eventElement, seg) { + var isStart = seg.isStart; var origWidth; var revert; - var allDay=true; + var allDay = true; var dayDelta; - var dis = opt('isRTL') ? -1 : 1; var hoverListener = getHoverListener(); var colWidth = getColWidth(); - var slotHeight = getSlotHeight(); + var snapHeight = getSnapHeight(); + var snapMinutes = getSnapMinutes(); var minMinute = getMinMinute(); eventElement.draggable({ - zIndex: 9, opacity: opt('dragOpacity', 'month'), // use whatever the month view was using revertDuration: opt('dragRevertDuration'), start: function(ev, ui) { trigger('eventDragStart', eventElement, event, ev, ui); hideEvents(event, eventElement); origWidth = eventElement.width(); - hoverListener.start(function(cell, origCell, rowDelta, colDelta) { + hoverListener.start(function(cell, origCell) { clearOverlays(); if (cell) { - //setOverflowHidden(true); revert = false; - dayDelta = colDelta * dis; + var origDate = cellToDate(0, origCell.col); + var date = cellToDate(0, cell.col); + dayDelta = dayDiff(date, origDate); if (!cell.row) { // on full-days renderDayOverlay( @@ -3999,9 +4068,9 @@ function AgendaEventRenderer() { eventElement.width(colWidth - 10); // don't use entire width setOuterHeight( eventElement, - slotHeight * Math.round( - (event.end ? ((event.end - event.start) / MINUTE_MS) : opt('defaultEventMinutes')) - / opt('slotMinutes') + snapHeight * Math.round( + (event.end ? ((event.end - event.start) / MINUTE_MS) : opt('defaultEventMinutes')) / + snapMinutes ) ); eventElement.draggable('option', 'grid', [colWidth, 1]); @@ -4014,7 +4083,6 @@ function AgendaEventRenderer() { revert = revert || (allDay && !dayDelta); }else{ resetElement(); - //setOverflowHidden(false); revert = true; } eventElement.draggable('option', 'revert', revert); @@ -4033,14 +4101,13 @@ function AgendaEventRenderer() { // changed! var minuteDelta = 0; if (!allDay) { - minuteDelta = Math.round((eventElement.offset().top - getBodyContent().offset().top) / slotHeight) - * opt('slotMinutes') + minuteDelta = Math.round((eventElement.offset().top - getSlotContainer().offset().top) / snapHeight) + * snapMinutes + minMinute - (event.start.getHours() * 60 + event.start.getMinutes()); } eventDrop(this, event, dayDelta, minuteDelta, allDay, ev, ui); } - //setOverflowHidden(false); } }); function resetElement() { @@ -4058,78 +4125,147 @@ function AgendaEventRenderer() { // when event starts out IN TIMESLOTS function draggableSlotEvent(event, eventElement, timeElement) { - var origPosition; - var allDay=false; - var dayDelta; - var minuteDelta; - var prevMinuteDelta; - var dis = opt('isRTL') ? -1 : 1; - var hoverListener = getHoverListener(); + var coordinateGrid = t.getCoordinateGrid(); var colCnt = getColCnt(); var colWidth = getColWidth(); - var slotHeight = getSlotHeight(); + var snapHeight = getSnapHeight(); + var snapMinutes = getSnapMinutes(); + + // states + var origPosition; // original position of the element, not the mouse + var origCell; + var isInBounds, prevIsInBounds; + var isAllDay, prevIsAllDay; + var colDelta, prevColDelta; + var dayDelta; // derived from colDelta + var minuteDelta, prevMinuteDelta; + eventElement.draggable({ - zIndex: 9, scroll: false, - grid: [colWidth, slotHeight], + grid: [ colWidth, snapHeight ], axis: colCnt==1 ? 'y' : false, opacity: opt('dragOpacity'), revertDuration: opt('dragRevertDuration'), start: function(ev, ui) { + trigger('eventDragStart', eventElement, event, ev, ui); hideEvents(event, eventElement); + + coordinateGrid.build(); + + // initialize states origPosition = eventElement.position(); + origCell = coordinateGrid.cell(ev.pageX, ev.pageY); + isInBounds = prevIsInBounds = true; + isAllDay = prevIsAllDay = getIsCellAllDay(origCell); + colDelta = prevColDelta = 0; + dayDelta = 0; minuteDelta = prevMinuteDelta = 0; - hoverListener.start(function(cell, origCell, rowDelta, colDelta) { - eventElement.draggable('option', 'revert', !cell); - clearOverlays(); - if (cell) { - dayDelta = colDelta * dis; - if (opt('allDaySlot') && !cell.row) { - // over full days - if (!allDay) { - // convert to temporary all-day event - allDay = true; - timeElement.hide(); - eventElement.draggable('option', 'grid', null); - } - renderDayOverlay( - addDays(cloneDate(event.start), dayDelta), - addDays(exclEndDay(event), dayDelta) - ); - }else{ - // on slots - resetElement(); - } - } - }, ev, 'drag'); + }, drag: function(ev, ui) { - minuteDelta = Math.round((ui.position.top - origPosition.top) / slotHeight) * opt('slotMinutes'); - if (minuteDelta != prevMinuteDelta) { - if (!allDay) { - updateTimeText(minuteDelta); + + // NOTE: this `cell` value is only useful for determining in-bounds and all-day. + // Bad for anything else due to the discrepancy between the mouse position and the + // element position while snapping. (problem revealed in PR #55) + // + // PS- the problem exists for draggableDayEvent() when dragging an all-day event to a slot event. + // We should overhaul the dragging system and stop relying on jQuery UI. + var cell = coordinateGrid.cell(ev.pageX, ev.pageY); + + // update states + isInBounds = !!cell; + if (isInBounds) { + isAllDay = getIsCellAllDay(cell); + + // calculate column delta + colDelta = Math.round((ui.position.left - origPosition.left) / colWidth); + if (colDelta != prevColDelta) { + // calculate the day delta based off of the original clicked column and the column delta + var origDate = cellToDate(0, origCell.col); + var col = origCell.col + colDelta; + col = Math.max(0, col); + col = Math.min(colCnt-1, col); + var date = cellToDate(0, col); + dayDelta = dayDiff(date, origDate); } + + // calculate minute delta (only if over slots) + if (!isAllDay) { + minuteDelta = Math.round((ui.position.top - origPosition.top) / snapHeight) * snapMinutes; + } + } + + // any state changes? + if ( + isInBounds != prevIsInBounds || + isAllDay != prevIsAllDay || + colDelta != prevColDelta || + minuteDelta != prevMinuteDelta + ) { + + updateUI(); + + // update previous states for next time + prevIsInBounds = isInBounds; + prevIsAllDay = isAllDay; + prevColDelta = colDelta; prevMinuteDelta = minuteDelta; } + + // if out-of-bounds, revert when done, and vice versa. + eventElement.draggable('option', 'revert', !isInBounds); + }, stop: function(ev, ui) { - var cell = hoverListener.stop(); + clearOverlays(); trigger('eventDragStop', eventElement, event, ev, ui); - if (cell && (dayDelta || minuteDelta || allDay)) { - // changed! - eventDrop(this, event, dayDelta, allDay ? 0 : minuteDelta, allDay, ev, ui); - }else{ - // either no change or out-of-bounds (draggable has already reverted) - resetElement(); + + if (isInBounds && (isAllDay || dayDelta || minuteDelta)) { // changed! + eventDrop(this, event, dayDelta, isAllDay ? 0 : minuteDelta, isAllDay, ev, ui); + } + else { // either no change or out-of-bounds (draggable has already reverted) + + // reset states for next time, and for updateUI() + isInBounds = true; + isAllDay = false; + colDelta = 0; + dayDelta = 0; + minuteDelta = 0; + + updateUI(); eventElement.css('filter', ''); // clear IE opacity side-effects - eventElement.css(origPosition); // sometimes fast drags make event revert to wrong position - updateTimeText(0); + + // sometimes fast drags make event revert to wrong position, so reset. + // also, if we dragged the element out of the area because of snapping, + // but the *mouse* is still in bounds, we need to reset the position. + eventElement.css(origPosition); + showEvents(event, eventElement); } } }); + + function updateUI() { + clearOverlays(); + if (isInBounds) { + if (isAllDay) { + timeElement.hide(); + eventElement.draggable('option', 'grid', null); // disable grid snapping + renderDayOverlay( + addDays(cloneDate(event.start), dayDelta), + addDays(exclEndDay(event), dayDelta) + ); + } + else { + updateTimeText(minuteDelta); + timeElement.css('display', ''); // show() was causing display=inline + eventElement.draggable('option', 'grid', [colWidth, snapHeight]); // re-enable grid snapping + } + } + } + function updateTimeText(minuteDelta) { var newStart = addMinutes(cloneDate(event.start), minuteDelta); var newEnd; @@ -4138,14 +4274,7 @@ function AgendaEventRenderer() { } timeElement.text(formatDates(newStart, newEnd, opt('timeFormat'))); } - function resetElement() { - // convert back to original slot-event - if (allDay) { - timeElement.css('display', ''); // show() was causing display=inline - eventElement.draggable('option', 'grid', [colWidth, slotHeight]); - allDay = false; - } - } + } @@ -4155,40 +4284,39 @@ function AgendaEventRenderer() { function resizableSlotEvent(event, eventElement, timeElement) { - var slotDelta, prevSlotDelta; - var slotHeight = getSlotHeight(); + var snapDelta, prevSnapDelta; + var snapHeight = getSnapHeight(); + var snapMinutes = getSnapMinutes(); eventElement.resizable({ handles: { - s: 'div.ui-resizable-s' + s: '.ui-resizable-handle' }, - grid: slotHeight, + grid: snapHeight, start: function(ev, ui) { - slotDelta = prevSlotDelta = 0; + snapDelta = prevSnapDelta = 0; hideEvents(event, eventElement); - eventElement.css('z-index', 9); trigger('eventResizeStart', this, event, ev, ui); }, resize: function(ev, ui) { // don't rely on ui.size.height, doesn't take grid into account - slotDelta = Math.round((Math.max(slotHeight, eventElement.height()) - ui.originalSize.height) / slotHeight); - if (slotDelta != prevSlotDelta) { + snapDelta = Math.round((Math.max(snapHeight, eventElement.height()) - ui.originalSize.height) / snapHeight); + if (snapDelta != prevSnapDelta) { timeElement.text( formatDates( event.start, - (!slotDelta && !event.end) ? null : // no change, so don't display time range - addMinutes(eventEnd(event), opt('slotMinutes')*slotDelta), + (!snapDelta && !event.end) ? null : // no change, so don't display time range + addMinutes(eventEnd(event), snapMinutes*snapDelta), opt('timeFormat') ) ); - prevSlotDelta = slotDelta; + prevSnapDelta = snapDelta; } }, stop: function(ev, ui) { trigger('eventResizeStop', this, event, ev, ui); - if (slotDelta) { - eventResize(this, event, 0, opt('slotMinutes')*slotDelta, ev, ui); + if (snapDelta) { + eventResize(this, event, 0, snapMinutes*snapDelta, ev, ui); }else{ - eventElement.css('z-index', 8); showEvents(event, eventElement); // BUG: if event was really short, need to put title back in span } @@ -4200,23 +4328,213 @@ function AgendaEventRenderer() { } -function countForwardSegs(levels) { - var i, j, k, level, segForward, segBack; - for (i=levels.length-1; i>0; i--) { + +/* Agenda Event Segment Utilities +-----------------------------------------------------------------------------*/ + + +// Sets the seg.backwardCoord and seg.forwardCoord on each segment and returns a new +// list in the order they should be placed into the DOM (an implicit z-index). +function placeSlotSegs(segs) { + var levels = buildSlotSegLevels(segs); + var level0 = levels[0]; + var i; + + computeForwardSlotSegs(levels); + + if (level0) { + + for (i=0; i seg2.start && seg1.start < seg2.end; +} + + +// A cmp function for determining which forward segment to rely on more when computing coordinates. +function compareForwardSlotSegs(seg1, seg2) { + // put higher-pressure first + return seg2.forwardPressure - seg1.forwardPressure || + // put segments that are closer to initial edge first (and favor ones with no coords yet) + (seg1.backwardCoord || 0) - (seg2.backwardCoord || 0) || + // do normal sorting... + compareSlotSegs(seg1, seg2); +} + + +// A cmp function for determining which segment should be closer to the initial edge +// (the left edge on a left-to-right calendar). +function compareSlotSegs(seg1, seg2) { + return seg1.start - seg2.start || // earlier start time goes first + (seg2.end - seg2.start) - (seg1.end - seg1.start) || // tie? longer-duration goes first + (seg1.event.title || '').localeCompare(seg2.event.title); // tie? alphabetically by title +} + + +;; function View(element, calendar, viewName) { @@ -4229,13 +4547,13 @@ function View(element, calendar, viewName) { t.name = viewName; t.opt = opt; t.trigger = trigger; - //t.setOverflowHidden = setOverflowHidden; t.isEventDraggable = isEventDraggable; t.isEventResizable = isEventResizable; - t.reportEvents = reportEvents; + t.setEventData = setEventData; + t.clearEventData = clearEventData; t.eventEnd = eventEnd; t.reportEventElement = reportEventElement; - t.reportEventClear = reportEventClear; + t.triggerEventDestroy = triggerEventDestroy; t.eventElementHandlers = eventElementHandlers; t.showEvents = showEvents; t.hideEvents = hideEvents; @@ -4253,16 +4571,16 @@ function View(element, calendar, viewName) { // locals - var eventsByID = {}; - var eventElements = []; - var eventElementsByID = {}; + var eventsByID = {}; // eventID mapped to array of events (there can be multiple b/c of repeating events) + var eventElementsByID = {}; // eventID mapped to array of jQuery elements + var eventElementCouples = []; // array of objects, { event, element } // TODO: unify with segment system var options = calendar.options; function opt(name, viewNameOverride) { var v = options[name]; - if (typeof v == 'object') { + if ($.isPlainObject(v)) { return smartProperty(v, viewNameOverride || viewName); } return v; @@ -4276,26 +4594,37 @@ function View(element, calendar, viewName) { ); } - - /* - function setOverflowHidden(bool) { - element.css('overflow', bool ? 'hidden' : ''); - } - */ - + + + /* Event Editable Boolean Calculations + ------------------------------------------------------------------------------*/ + function isEventDraggable(event) { - return isEventEditable(event) && !opt('disableDragging'); + var source = event.source || {}; + return firstDefined( + event.startEditable, + source.startEditable, + opt('eventStartEditable'), + event.editable, + source.editable, + opt('editable') + ) + && !opt('disableDragging'); // deprecated } function isEventResizable(event) { // but also need to make sure the seg.isEnd == true - return isEventEditable(event) && !opt('disableResizing'); - } - - - function isEventEditable(event) { - return firstDefined(event.editable, (event.source || {}).editable, opt('editable')); + var source = event.source || {}; + return firstDefined( + event.durationEditable, + source.durationEditable, + opt('eventDurationEditable'), + event.editable, + source.editable, + opt('editable') + ) + && !opt('disableResizing'); // deprecated } @@ -4304,8 +4633,7 @@ function View(element, calendar, viewName) { ------------------------------------------------------------------------------*/ - // report when view receives new events - function reportEvents(events) { // events are already normalized at this point + function setEventData(events) { // events are already normalized at this point eventsByID = {}; var i, len=events.length, event; for (i=0; i