Changeset 685


Ignore:
Timestamp:
11/28/2011 09:02:00 AM (6 months ago)
Author:
ofer
Message:

Fix error with translate post and on_publish when an iframe was included in the page

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/WordPress/plugin/transposh/core/parser.php

    r667 r685  
    2828    /** @var int Holds the total phrases the parser encountered */ 
    2929    public $total_phrases; 
     30 
    3031    /** @var int Holds the number of phrases that had translation */ 
    3132    public $translated_phrases; 
     33 
    3234    /** @var int Holds the number of phrases that had human translation */ 
    3335    public $human_translated_phrases; 
     36 
    3437    /** @var int Holds the number of phrases that are hidden - yet still somewhat viewable (such as the title attribure) */ 
    3538    public $hidden_phrases; 
     39 
    3640    /** @var int Holds the number of phrases that are hidden and translated */ 
    3741    public $hidden_translated_phrases; 
     42 
    3843    /** @var int Holds the amounts of hidden spans created for translation */ 
    3944    public $hidden_translateable_phrases; 
     45 
    4046    /** @var int Holds the number of phrases that are hidden and probably won't be viewed - such as meta keys */ 
    4147    public $meta_phrases; 
     48 
    4249    /** @var int Holds the number of translated phrases that are hidden and probably won't be viewed - such as meta keys */ 
    4350    public $meta_translated_phrases; 
     51 
    4452    /** @var float Holds the time translation took */ 
    4553    public $time; 
     54 
    4655    /** @var int Holds the time translation started */ 
    4756    private $start_time; 
     
    96105    public $prefetch_translate_func = null; 
    97106    public $split_url_func = null; 
     107 
    98108    /** @var int stores the number of the last used span_id */ 
    99109    private $span_id = 0; 
     110 
    100111    /** @var simple_html_dom_node Contains the current node */ 
    101112    private $currentnode; 
     113 
    102114    /** @var simple_html_dom Contains the document dom model */ 
    103115    private $html; 
    104116    // the document 
    105117    public $dir_rtl; 
     118 
    106119    /** @var string Contains the iso of the target language */ 
    107120    public $lang; 
     121 
    108122    /** @var boolean Contains the fact that this language is the default one (only parse other lanaguage spans) */ 
    109123    public $default_lang = false; 
     124 
    110125    /** @var string Contains the iso of the source language - if a lang attribute is found, assumed to be en by default */ 
    111126    public $srclang; 
    112127    private $inbody = false; 
     128 
    113129    /** @var hold fact that we are in select or other similar elements */ 
    114130    private $inselect = false; 
     
    116132    public $is_auto_translate; 
    117133    public $feed_fix; 
     134 
    118135    /** @var boolean should we attempt to handle page as json */ 
    119136    public $might_json = false; 
     
    121138    //first three are html, later 3 come from feeds xml (link is problematic...) 
    122139    protected $ignore_tags = array('script' => 1, 'style' => 1, 'code' => 1, 'wfw:commentrss' => 1, 'comments' => 1, 'guid' => 1); 
     140 
    123141    /** @var parserstats Contains parsing statistics */ 
    124142    private $stats; 
     143 
    125144    /** @var boolean Are we inside a translated gettext */ 
    126145    private $in_get_text = false; 
     146 
    127147    /** @var boolean Are we inside an inner text %s in gettext */ 
    128148    private $in_get_text_inner = false; 
     149 
    129150    /** @var string Additional header information */ 
    130151    public $added_header; 
     152 
    131153    /** @var array Contains reference to changable a tags */ 
    132154    private $atags = array(); 
     155 
    133156    /** @var array Contains reference to changable option values */ 
    134157    private $otags = array(); 
     
    513536        // for iframes we will rewrite urls if we can 
    514537        elseif ($node->tag == 'iframe') { 
    515             $node->src = call_user_func_array($this->url_rewrite_func, array($node->src)); 
    516             logger($node->src); 
     538            if ($this->url_rewrite_func) { 
     539                $node->src = call_user_func_array($this->url_rewrite_func, array($node->src)); 
     540                logger($node->src); 
     541            } 
    517542        } 
    518543 
     
    521546 
    522547        // Meta content (keywords, description) are also good places to translate (but not in robots... or http-equiv) 
    523         if ($node->tag == 'meta' && $node->content && ($node->name != 'robots') && ($node->name != 'viewport')&& ($node->{'http-equiv'} != 'Content-Type')) 
     548        if ($node->tag == 'meta' && $node->content && ($node->name != 'robots') && ($node->name != 'viewport') && ($node->{'http-equiv'} != 'Content-Type')) 
    524549                $this->parsetext($node->content); 
    525550 
     
    867892        // we might show an ad for transposh in some cases 
    868893        if (($this->allow_ad && !$this->default_lang && mt_rand(1, 100) > 95) || // 5 of 100 for translated non default language pages 
    869             ($this->allow_ad && $this->default_lang && mt_rand(1, 100) > 99) || // 1 of 100 for translated default languages pages 
    870             (!$this->allow_ad && mt_rand(1, 1000) > 999)) { // 1 of 1000 otherwise 
     894                ($this->allow_ad && $this->default_lang && mt_rand(1, 100) > 99) || // 1 of 100 for translated default languages pages 
     895                (!$this->allow_ad && mt_rand(1, 1000) > 999)) { // 1 of 1000 otherwise 
    871896            $this->do_ad_switch(); 
    872897        } 
Note: See TracChangeset for help on using the changeset viewer.