Exemplo n.º 1
0
 public function body()
 {
     load_js('modules/Base/Help/js/canvasutilities.js');
     load_js('modules/Base/Help/js/main.js');
     eval_js('Helper.stop_tutorial_message = "' . Epesi::escapeJS('Tutorial was stopped') . '";');
     eval_js('setTimeout("Helper.get_all_help_hooks();", 500);');
     $theme = $this->init_module('Base_Theme');
     $theme->assign('href', 'href="javascript:void(0);" onclick="Helper.menu()"');
     $theme->assign('search_placeholder', __('Start typing to search help topics'));
     $theme->assign('label', __('Help'));
     Utils_ShortcutCommon::add(array('esc'), 'function(){Helper.escape();}');
     Utils_ShortcutCommon::add(array('f1'), 'function(){Helper.menu();}');
     $theme->display();
 }
Exemplo n.º 2
0
 public static function add($keys, $func, $opts = array())
 {
     if (isset($_REQUEST['__location']) && self::$clean !== $_REQUEST['__location'] || self::$clean === false) {
         self::$clean = isset($_REQUEST['__location']) ? $_REQUEST['__location'] : true;
         eval_js('shortcut.remove_all();');
     }
     $js = 'shortcut.add("' . implode('+', $keys) . '",' . $func . ',{';
     $js .= '\'type\':\'' . (isset($opts['type']) ? $opts['type'] : 'keydown') . '\',';
     $js .= '\'propagate\':' . (isset($opts['propagate']) ? $opts['propagate'] : 'false') . ',';
     $js .= '\'disable_in_input\':' . (isset($opts['disable_in_input']) ? $opts['disable_in_input'] : 'false') . ',';
     $js .= '\'target\':' . (isset($opts['target']) ? $opts['target'] : 'document');
     $js .= '});';
     eval_js($js);
 }
Exemplo n.º 3
0
 public static function homepage_icon()
 {
     Utils_ShortcutCommon::add(array('Ctrl', 'H'), 'function(){' . Module::create_href_js(array('Base_HomePage_load' => '1')) . '}');
 }
Exemplo n.º 4
0
    public function view_entry($mode='view', $id = null, $defaults = array(), $show_actions=true) {
		Base_HelpCommon::screen_name('rb_'.$mode.'_'.$this->tab);
        if (isset($_SESSION['client']['recordbrowser']['admin_access'])) Utils_RecordBrowserCommon::$admin_access = true;
        self::$mode = $mode;
        if ($this->navigation_executed) {
            $this->navigation_executed = false;
            return true;
        }
        if ($this->check_for_jump()) return;
        $theme = $this->init_module('Base/Theme');
        if ($this->isset_module_variable('id')) {
            $id = $this->get_module_variable('id');
            $this->unset_module_variable('id');
        }
        self::$browsed_records = null;

        Utils_RecordBrowserCommon::$cols_order = array();
        $js = ($mode!='view');
        $time = microtime(true);
        if ($this->is_back()) {
            self::$clone_result = 'canceled';
            return $this->back();
        }

        $this->init();
		if (is_numeric($id)) {
	                $id = intVal($id);
			self::$last_record = $this->record = Utils_RecordBrowserCommon::get_record($this->tab, $id, $mode!=='edit');
		} else {
			self::$last_record = $this->record = $id;
			$id = intVal($this->record['id']);
		}
		if ($id===0) $id = null;
        if ($id!==null && is_numeric($id)) Utils_WatchdogCommon::notified($this->tab,$id);

        if($mode=='add') {
            foreach ($defaults as $k=>$v)
                $this->custom_defaults[$k] = $v;
            foreach($this->table_rows as $field => $args)
                if (!isset($this->custom_defaults[$args['id']]))
					$this->custom_defaults[$args['id']] = $args['type'] == 'multiselect' ? array() : '';
			$this->custom_defaults['created_by'] = Acl::get_user();
		}

        $access = $this->get_access($mode=='history'?'view':$mode, isset($this->record)?$this->record:$this->custom_defaults);
        if ($mode=='edit' || $mode=='add')
            $this->view_fields_permission = $this->get_access('view', isset($this->record)?$this->record:$this->custom_defaults);
        else
            $this->view_fields_permission = $access;

        if ($mode!='add' && (!$access || $this->record==null)) {
            if (Base_AclCommon::i_am_admin()) {
                Utils_RecordBrowserCommon::$admin_access = true;
                $access = $this->get_access($mode, isset($this->record)?$this->record:$this->custom_defaults);
                if ($mode=='edit' || $mode=='add')
                    $this->view_fields_permission = $this->get_access('view', isset($this->record)?$this->record:$this->custom_defaults);
                else
                    $this->view_fields_permission = $access;
            } else {
                print(__('You don\'t have permission to view this record.'));
                if ($show_actions===true || (is_array($show_actions) && (!isset($show_actions['back']) || $show_actions['back']))) {
                    Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
                    //Utils_ShortcutCommon::add(array('esc'), 'function(){'.$this->create_back_href_js().'}');
                }
                return true;
            }
        }
        if ($mode=='add' && !$access) {
			print(__('You don\'t have permission to perform this action.'));
			if ($show_actions===true || (is_array($show_actions) && (!isset($show_actions['back']) || $show_actions['back']))) {
				Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
				//Utils_ShortcutCommon::add(array('esc'), 'function(){'.$this->create_back_href_js().'}');
			}
			return true;
		}

        if($mode == 'add' || $mode == 'edit') {
            $theme -> assign('click2fill', '<div id="c2fBox"></div>');
            load_js('modules/Utils/RecordBrowser/click2fill.js');
            eval_js('initc2f("'.__('Scan/Edit').'","'.__('Paste data here with Ctrl-v, click button below, then click on separated words in specific order and click in text field where you want put those words. They will replace text in that field.').'")');
            Base_ActionBarCommon::add('clone', __('Click 2 Fill'), 'href="javascript:void(0)" onclick="c2f()"');
        }

//        if ($mode!='add' && !$this->record[':active'] && !Base_AclCommon::i_am_admin()) return $this->back();

        $tb = $this->init_module('Utils/TabbedBrowser', null, 'recordbrowser_addons');
		if ($mode=='history') $tb->set_inline_display();
        self::$tab_param = $tb->get_path();

        $form = $this->init_module('Libs/QuickForm',null, $mode);
        if(Base_User_SettingsCommon::get($this->get_type(), 'confirm_leave') && ($mode == 'add' || $mode == 'edit'))
        	$form->set_confirm_leave_page();
        
        $this->form = $form;

        if($mode!='add')
            Utils_RecordBrowserCommon::add_recent_entry($this->tab, Acl::get_user(),$id);

		$dp = Utils_RecordBrowserCommon::record_processing($this->tab, $mode!='add'?$this->record:$this->custom_defaults, ($mode=='view' || $mode=='history')?'view':$mode.'ing');
		if($dp===false) return false;
		if (is_array($dp))
			$defaults = $this->custom_defaults = self::$last_record = $this->record = $dp;

        if (self::$last_record===null) self::$last_record = $defaults;
        if($mode=='add')
            $form->setDefaults($defaults);

        switch ($mode) {
            case 'add':     $this->action = _M('New record'); break;
            case 'edit':    $this->action = _M('Edit record'); break;
            case 'view':    $this->action = _M('View record'); break;
            case 'history':    $this->action = _M('Record history view'); break;
        }

        $this->prepare_view_entry_details($this->record, $mode=='history'?'view':$mode, $id, $form);

        if ($mode==='edit' || $mode==='add')
            foreach($this->table_rows as $field => $args) {
                if (!$access[$args['id']])
                    $form->freeze($args['id']);
            }
        if ($form->exportValue('submited') && $form->validate()) {
            $values = $form->exportValues();
			
			foreach ($defaults as $k=>$v) {
				if (!isset($values[$k]) && isset($this->view_fields_permission[$k]) && !$this->view_fields_permission[$k]) $values[$k] = $v;
				if (isset($access[$k]) && !$access[$k]) $values[$k] = $v;
			}
            foreach ($this->table_rows as $v) {
                if ($v['type']=='checkbox' && !isset($values[$v['id']])) $values[$v['id']]=0;
            }
            $values['id'] = $id;
            foreach ($this->custom_defaults as $k=>$v)
                if (!isset($values[$k])) $values[$k] = $v;
            if ($mode=='add') {
                $id = Utils_RecordBrowserCommon::new_record($this->tab, $values);
                self::$clone_result = $id;
                self::$clone_tab = $this->tab;
                return $this->back();
            }
            $time_from = date('Y-m-d H:i:s', $this->get_module_variable('edit_start_time'));
            $ret = DB::Execute('SELECT * FROM '.$this->tab.'_edit_history WHERE edited_on>=%T AND edited_on<=%T AND '.$this->tab.'_id=%d',array($time_from, date('Y-m-d H:i:s'), $id));
            if ($ret->EOF) {
                $this->update_record($id,$values);
                return $this->back();
            }
            $this->dirty_read_changes($id, $time_from);
        }
		$form->add_error_closing_buttons();

        if (($mode=='edit' || $mode=='add') && $show_actions!==false) {
            Utils_ShortcutCommon::add(array('Ctrl','S'), 'function(){'.$form->get_submit_form_js().'}');
        }
        if ($mode=='edit') {
            $this->set_module_variable('edit_start_time',$time);
        }

        if ($show_actions!==false) {
            if ($mode=='view') {
                if ($this->get_access('edit',$this->record)) {
                    Base_ActionBarCommon::add('edit', __('Edit'), $this->create_callback_href(array($this,'navigate'), array('view_entry','edit',$id)));
                    Utils_ShortcutCommon::add(array('Ctrl','E'), 'function(){'.$this->create_callback_href_js(array($this,'navigate'), array('view_entry','edit',$id)).'}');
                }
                if ($this->get_access('delete',$this->record)) {
                    Base_ActionBarCommon::add('delete', __('Delete'), $this->create_confirm_callback_href(__('Are you sure you want to delete this record?'),array($this,'delete_record'),array($id)));
                }
                if ($this->get_access('add',$this->record)) {
                    Base_ActionBarCommon::add('clone',__('Clone'), $this->create_confirm_callback_href(__('You are about to create a copy of this record. Do you want to continue?'),array($this,'clone_record'),array($id)));
                }
                /** @var Base_Print_Printer $printer */
                $printer = Utils_RecordBrowserCommon::get_printer($this->tab);
                if ($printer) {
                    Base_ActionBarCommon::add('print', __('Print'), $printer->get_href(array('tab' => $this->tab, 'record_id' => $this->record['id'])));
                }
                if ($show_actions===true || (is_array($show_actions) && (!isset($show_actions['back']) || $show_actions['back'])))
                    Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
            } elseif($mode!='history') {
                Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
                Base_ActionBarCommon::add('delete', __('Cancel'), $this->create_back_href());
            }
            //Utils_ShortcutCommon::add(array('esc'), 'function(){'.$this->create_back_href_js().'}');
        }

        if ($mode!='add') {
            $theme -> assign('info_tooltip', '<a '.Utils_TooltipCommon::open_tag_attrs(Utils_RecordBrowserCommon::get_html_record_info($this->tab, $id)).'><img border="0" src="'.Base_ThemeCommon::get_template_file('Utils_RecordBrowser','info.png').'" /></a>');
            $row_data= array();

			if ($mode!='history') {
				if ($this->favorites)
					$theme -> assign('fav_tooltip', Utils_RecordBrowserCommon::get_fav_button($this->tab, $id));
				if ($this->watchdog)
					$theme -> assign('subscription_tooltip', Utils_WatchdogCommon::get_change_subscription_icon($this->tab, $id));
				if ($this->full_history) {
					$info = Utils_RecordBrowserCommon::get_record_info($this->tab, $id);
					if ($info['edited_on']===null) $theme -> assign('history_tooltip', '<a '.Utils_TooltipCommon::open_tag_attrs(__('This record was never edited')).'><img border="0" src="'.Base_ThemeCommon::get_template_file('Utils_RecordBrowser','history_inactive.png').'" /></a>');
					else $theme -> assign('history_tooltip', '<a '.Utils_TooltipCommon::open_tag_attrs(__('Click to view edit history of currently displayed record')).' '.$this->create_callback_href(array($this,'navigate'), array('view_edit_history', $id)).'><img border="0" src="'.Base_ThemeCommon::get_template_file('Utils_RecordBrowser','history.png').'" /></a>');
				}
				if ($this->clipboard_pattern) {
					$theme -> assign('clipboard_tooltip', '<a '.Utils_TooltipCommon::open_tag_attrs(__('Click to export values to copy')).' '.Libs_LeightboxCommon::get_open_href('clipboard').'><img border="0" src="'.Base_ThemeCommon::get_template_file('Utils_RecordBrowser','clipboard.png').'" /></a>');
					$text = $this->clipboard_pattern;
					$record = Utils_RecordBrowserCommon::get_record($this->tab, $id);
					/* for every field name store its value */
					$data = array();
					foreach($this->table_rows as $val) {
						$fval = Utils_RecordBrowserCommon::get_val($this->tab, $val['id'], $record, true);
						if(strlen($fval)) $data[$val['id']] = $fval;
					}
					/* some complicate preg match to find every occurence
					 * of %{ .. {f_name} .. } pattern
					 */
                    if (preg_match_all('/%\{(([^%\}\{]*?\{[^%\}\{]+?\}[^%\}\{]*?)+?)\}/', $text, $match)) { // match for all patterns %{...{..}...}
                        foreach ($match[0] as $k => $matched_string) {
                            $text_replace = $match[1][$k];
                            $changed = false;
                            while(preg_match('/\{(.+?)\}/', $text_replace, $second_match)) { // match for keys in braces {key}
                                $replace_value = '';
                                if(array_key_exists($second_match[1], $data)) {
                                    $replace_value = $data[$second_match[1]];
                                    $changed = true;
                                }
                                $text_replace = str_replace($second_match[0], $replace_value, $text_replace);
                            }
                            if(! $changed ) $text_replace = '';
                            $text = str_replace($matched_string, $text_replace, $text);
                        }
                    }
					load_js("modules/Utils/RecordBrowser/selecttext.js");
					/* remove all php new lines, replace <br>|<br/> to new lines and quote all special chars */
					$ftext = htmlspecialchars(preg_replace('#<[bB][rR]/?>#', "\n", str_replace("\n", '', $text)));
					$flash_copy = '<object width="60" height="20">'.
								'<param name="FlashVars" value="txtToCopy='.$ftext.'">'.
								'<param name="movie" value="'.$this->get_module_dir().'copyButton.swf">'.
								'<embed src="'.$this->get_module_dir().'copyButton.swf" flashvars="txtToCopy='.$ftext.'" width="60" height="20">'.
								'</embed>'.
								'</object>';
					$text = '<h3>'.__('Click Copy under the box or move mouse over box below to select text and hit Ctrl-c to copy it.').'</h3><div onmouseover="fnSelect(this)" style="border: 1px solid gray; margin: 15px; padding: 20px;">'.$text.'</div>'.$flash_copy;

					Libs_LeightboxCommon::display('clipboard',$text,__('Copy'));
				}
			}
        }

		if ($mode=='view') {
			$dp = Utils_RecordBrowserCommon::record_processing($this->tab, $this->record, 'display');
			if ($dp && is_array($dp))
				foreach ($dp as $k=>$v)
					$theme->assign($k, $v);
		}

        if ($mode=='view' || $mode=='history') $form->freeze();
        $renderer = new HTML_QuickForm_Renderer_TCMSArraySmarty();
        $form->accept($renderer);
        $data = $renderer->toArray();

        print($data['javascript'].'<form '.$data['attributes'].'>'.$data['hidden']."\n");

        $last_page = DB::GetOne('SELECT MIN(position) FROM '.$this->tab.'_field WHERE type = \'page_split\' AND field != \'General\'');
		if (!$last_page) $last_page = DB::GetOne('SELECT MAX(position) FROM '.$this->tab.'_field')+1;
        $label = DB::GetRow('SELECT field, param FROM '.$this->tab.'_field WHERE position=%s', array($last_page));
		if ($label) {
			$cols = $label['param'];
			$label = $label['field'];
		} else $cols = false;

        $this->view_entry_details(1, $last_page, $data, $theme, true);
        $ret = DB::Execute('SELECT position, field, param FROM '.$this->tab.'_field WHERE type = \'page_split\' AND position > %d ORDER BY position', array($last_page));
        $row = true;
        if ($mode=='view')
            print("</form>\n");
        $tab_counter=-1;
		$additional_tabs = 0;
		$default_tab = null;
        while ($row) {
            $row = $ret->FetchRow();
            if ($row) $pos = $row['position'];
            else $pos = DB::GetOne('SELECT MAX(position) FROM '.$this->tab.'_field WHERE active=1')+1;

            $valid_page = false;
			$hide_page = ($mode=='view' && Base_User_SettingsCommon::get('Utils/RecordBrowser','hide_empty'));
            foreach($this->table_rows as $field => $args) {
                if (!isset($data[$args['id']]) || $data[$args['id']]['type']=='hidden') continue;
                if ($args['position'] >= $last_page && ($pos+1 == -1 || $args['position'] < $pos+1)) {
                    $valid_page = true;
					if ($hide_page && !$this->field_is_empty($this->record, $args['id'])) $hide_page = false;
                    break;
                }
            }
            if ($valid_page && $pos - $last_page>1 && !isset($this->hide_tab[$label])) {
				$tb->set_tab(_V($label),array($this,'view_entry_details'), array($last_page, $pos+1, $data, null, false, $cols, _V($label)), $js); // TRSL
				if ($hide_page) {
					eval_js('$("'.$tb->get_tab_id(_V($label)).'").style.display="none";');
					if ($default_tab===($tab_counter+1) || $tb->get_tab()==($tab_counter+1)) $default_tab = $tab_counter+2;
				} else
					$additional_tabs++;
			}
            $cols = $row['param'];
            $last_page = $pos;
            if ($row) $label = $row['field'];
            $tab_counter++;
        }
		if ($default_tab!==null) $tb->set_default_tab($default_tab);
        if ($mode!='history') {
            $ret = DB::Execute('SELECT * FROM recordbrowser_addon WHERE tab=%s AND enabled=1 ORDER BY pos', array($this->tab));
            $addons_mod = array();
            while ($row = $ret->FetchRow()) {
                if (ModuleManager::is_installed($row['module'])==-1) continue;
                if (is_callable(explode('::',$row['label']))) {
                    $result = call_user_func(explode('::',$row['label']), $this->record, $this);
                    if (!isset($result['show'])) $result['show']=true;
					if (($mode=='add' || $mode=='edit') && (!isset($result['show_in_edit']) || !$result['show_in_edit'])) continue;
                    if ($result['show']==false) continue;
                    if (!isset($result['label'])) $result['label']='';
                    $row['label'] = $result['label'];
                } else {
					if ($mode=='add' || $mode=='edit') continue;
					$labels = explode('#',$row['label']);
					foreach($labels as $i=>$label) $labels[$i] = _V($label); // translate labels from database
					$row['label'] = implode('#',$labels);
				}
                $mod_id = md5(serialize($row));
				if (method_exists($row['module'].'Common',$row['func'].'_access') && !call_user_func(array($row['module'].'Common',$row['func'].'_access'), $this->record, $this)) continue;
                $addons_mod[$mod_id] = $this->init_module($row['module']);
                if (!method_exists($addons_mod[$mod_id],$row['func'])) $tb->set_tab($row['label'],array($this, 'broken_addon'), array(), $js);
                else $tb->set_tab($row['label'],array($this, 'display_module'), array(& $addons_mod[$mod_id], array($this->record, $this), $row['func']), $js);
            }
        }
        if ($additional_tabs==0 && ($mode=='add' || $mode=='edit' || $mode=='history'))
            print("</form>\n");
        $this->display_module($tb);
        $tb->tag();
		
		foreach ($this->fields_in_tabs as $label=>$fields) {
			$highlight = false;
			foreach ($fields as $f) {
				$err = $form->getElementError($f);
				if ($err) {
					$highlight = true;
					break;
				}
			}
			if ($highlight)
				$tb->tab_icon($label, Base_ThemeCommon::get_template_file('Utils_RecordBrowser','notify_error.png'));
		}
		
        if ($this->switch_to_addon) {
    	    $this->set_module_variable('switch_to_addon',false);
            if($tab_counter<0) $tab_counter=0;
            $ret = DB::Execute('SELECT * FROM recordbrowser_addon WHERE tab=%s AND enabled=1 ORDER BY pos', array($this->tab));
            while ($row = $ret->FetchRow()) {
                if (ModuleManager::is_installed($row['module'])==-1) continue;
                if (is_callable(explode('::',$row['label']))) {
                    $result = call_user_func(explode('::',$row['label']), $this->record,$this);
                    if (isset($result['show']) && $result['show']==false) continue;
                    $row['label'] = $result['label'];
                }
                if ($row['label']==$this->switch_to_addon) $this->switch_to_addon = $tab_counter;
                $tab_counter++;
            }
            $tb->switch_tab($this->switch_to_addon);
            location(array());
        }
        if ($additional_tabs!=0 && ($mode=='add' || $mode=='edit' || $mode=='history'))
            print("</form>\n");

        return true;
    } //view_entry
Exemplo n.º 5
0
 public function translations()
 {
     global $translations;
     global $custom_translations;
     load_js('modules/Base/Lang/Administrator/js/main.js');
     eval_js('translate_init();');
     $lp = $this->init_module('Utils/LeightboxPrompt');
     $form = $this->init_module('Libs/QuickForm', null, 'translations_sending');
     $desc = '<div id="trans_sett_info" style="line-height:17px;">';
     $desc .= __('You have now option to contribute with your translations to help us deliver EPESI in various languages. You can opt in to send your translations to EPESI central database, allowing to deliver EPESI in your language to other users.') . '<br>';
     $desc .= __('Please note that the translations you submit aren\'t subject to copyright. EPESI Team will distribute the translations free of charge to the end users.') . '<br>';
     $desc .= __('The only data being sent is the values of the fields presented below and the translated strings, we do not receive any other information contained in EPESI.') . '<br>';
     $desc .= __('You can also change your Translations Contribution settings at later time.') . '<br>';
     $desc .= '</div>';
     eval_js('$("trans_sett_info").up("td").setAttribute("colspan",2);');
     eval_js('$("trans_sett_info").up("td").style.borderRadius="0";');
     // Not really nice, but will have to do for now
     eval_js('$("decription_label").up("td").hide();');
     eval_js('function update_credits(){$("contact_email").disabled=$("credits_website").disabled=!$("include_credits").checked||!$("allow").checked;}');
     eval_js('update_credits();');
     $ip = gethostbyname($_SERVER['SERVER_NAME']);
     $me = CRM_ContactsCommon::get_my_record();
     $form->addElement('static', 'header', '<div id="decription_label" />', $desc);
     $form->addElement('checkbox', 'allow', __('Enable sending translations'), null, array('id' => 'allow', 'onchange' => '$("include_credits").disabled=$("first_name").disabled=$("last_name").disabled=!this.checked;update_credits();'));
     $form->addElement('text', 'first_name', __('First Name'), array('id' => 'first_name'));
     $form->addElement('text', 'last_name', __('Last Name'), array('id' => 'last_name'));
     $form->addElement('checkbox', 'include_credits', __('Include in credits'), null, array('id' => 'include_credits', 'onchange' => 'update_credits();'));
     $form->addElement('text', 'credits_website', __('Credits website'), array('id' => 'credits_website'));
     $form->addElement('text', 'contact_email', __('Contact e-mail'), array('id' => 'contact_email'));
     $form->addElement('static', 'IP', __('IP'), $ip);
     $lp->add_option(null, null, null, $form);
     eval_js('$("first_name").disabled=$("last_name").disabled=!$("allow").checked;');
     $vals = $lp->export_values();
     if ($vals) {
         $values = $vals['form'];
         if (!isset($values['allow'])) {
             $values['allow'] = 0;
         }
         if (!isset($values['first_name'])) {
             $values['first_name'] = '';
         }
         if (!isset($values['last_name'])) {
             $values['last_name'] = '';
         }
         if (!isset($values['include_credits'])) {
             $values['include_credits'] = 0;
         }
         if (!isset($values['credits_website'])) {
             $values['credits_website'] = '';
         }
         if (!isset($values['contact_email'])) {
             $values['contact_email'] = '';
         }
         DB::Execute('DELETE FROM base_lang_trans_contrib WHERE user_id=%d', array(Acl::get_user()));
         DB::Execute('INSERT INTO base_lang_trans_contrib (user_id, allow, first_name, last_name, credits, credits_website, contact_email) VALUES (%d, %d, %s, %s, %d, %s, %s)', array(Acl::get_user(), $values['allow'], $values['first_name'], $values['last_name'], $values['include_credits'], $values['credits_website'], $values['contact_email']));
     }
     $allow_sending = Base_Lang_AdministratorCommon::allow_sending(true);
     if ($allow_sending === null || $allow_sending === false) {
         $form->setDefaults(array('allow' => 0, 'first_name' => $me['first_name'], 'last_name' => $me['last_name'], 'contact_email' => $me['email']));
     } else {
         $r = DB::GetRow('SELECT * FROM base_lang_trans_contrib WHERE user_id=%d', array(Acl::get_user()));
         if (!$r['first_name']) {
             $r['first_name'] = $me['first_name'];
         }
         if (!$r['last_name']) {
             $r['last_name'] = $me['last_name'];
         }
         if (!$r['contact_email']) {
             $r['contact_email'] = $me['email'];
         }
         $form->setDefaults(array('allow' => $r['allow'], 'first_name' => $r['first_name'], 'last_name' => $r['last_name'], 'contact_email' => $r['contact_email'], 'credits_website' => $r['credits_website'], 'include_credits' => $r['credits']));
     }
     Base_ActionBarCommon::add('settings', __('Translations Contributions'), $lp->get_href());
     $this->display_module($lp, array(__('Translations Contributions settings')));
     if (Base_AdminCommon::get_access('Base_Lang_Administrator', 'new_langpack')) {
         Base_ActionBarCommon::add('add', __('New langpack'), $this->create_callback_href(array($this, 'new_lang_pack')));
     }
     if (Base_AdminCommon::get_access('Base_Lang_Administrator', 'select_language')) {
         Base_ActionBarCommon::add('refresh', __('Refresh languages'), $this->create_callback_href(array('Base_LangCommon', 'refresh_cache')));
     }
     $form2 = $this->init_module('Libs/QuickForm', null, 'translaction_filter');
     $form2->addElement('select', 'lang_filter', __('Filter'), array(__('Show all'), __('Show with custom translation'), __('Show with translation'), __('Show without translation')), array('onchange' => $form2->get_submit_form_js()));
     if ($form2->validate()) {
         $vals = $form2->exportValues();
         $this->set_module_variable('filter', $vals['lang_filter']);
     }
     $filter = $this->get_module_variable('filter', 0);
     $form2->setDefaults(array('lang_filter' => $filter));
     ob_start();
     $form2->display_as_row();
     $trans_filter = ob_get_clean();
     if (!isset($_SESSION['client']['base_lang_administrator']['currently_translating'])) {
         $_SESSION['client']['base_lang_administrator']['currently_translating'] = Base_LangCommon::get_lang_code();
     }
     if (!isset($_SESSION['client']['base_lang_administrator']['notice'])) {
         print '<span class="important_notice">' . __('Please make sure the correct language is selected in the box below before you start translating') . ' <a style="float:right;" ' . $this->create_callback_href(array($this, 'hide_notice')) . '>' . __('Discard') . '</a>' . '</span>';
     }
     if (Base_AdminCommon::get_access('Base_Lang_Administrator', 'translate')) {
         $langs = Base_LangCommon::get_installed_langs();
         $form = $this->init_module('Libs/QuickForm', null, 'language_selected');
         $form->addElement('select', 'lang_code', __('Currently Translating'), $langs, array('onchange' => $form->get_submit_form_js()));
         $currently_translating = $_SESSION['client']['base_lang_administrator']['currently_translating'];
         $form->setDefaults(array('lang_code' => $currently_translating));
         if ($form->validate()) {
             $form->process(array($this, 'submit_language_select'));
         }
         if ($allow_sending) {
             $warning_mgs = __('All custom translations will be sent to our server right after you will input them. Use this mode only, if you wish to contribute your translations. If you are going to change meaning of any string, then please disable sending translations.');
             print "<h1 style=\"color:red; width: 70%\">{$warning_mgs}</h1>";
         } else {
             $contribution_mgs = __('If you wish to help us with translating EPESI to your language, then click Translation Contribution in the Action Bar.');
             print "<h3>{$contribution_mgs}</h3>";
         }
         $form->display_as_column();
         if ($allow_sending) {
             $href = $this->create_confirm_callback_href(__('Are you sure?'), array($this, 'send_lang_ajax'), array($currently_translating));
             print "<h4><a {$href}>" . __('Send all your custom translations for language %s', array($langs[$currently_translating])) . "</a></h4>";
         }
         $help_msg = __('You can open next string to translate with space button');
         print "<p>{$help_msg}</p>";
     }
     Base_LangCommon::load($_SESSION['client']['base_lang_administrator']['currently_translating']);
     $data = array();
     foreach ($custom_translations as $o => $t) {
         if ($t || !isset($translations[$o])) {
             $translations[$o] = $t;
         }
     }
     foreach ($translations as $o => $t) {
         if (isset($custom_translations[$o]) && $custom_translations[$o]) {
             $t = $custom_translations[$o];
         } else {
             if ($filter == 1) {
                 continue;
             }
         }
         if ($filter == 2 && !$t) {
             continue;
         }
         if ($filter == 3 && $t) {
             continue;
         }
         $span_id = 'trans__' . md5($o);
         if (Base_AdminCommon::get_access('Base_Lang_Administrator', 'translate')) {
             $org = '<a href="javascript:void(0);" onclick="lang_translate(\'' . Epesi::escapeJS(htmlspecialchars($o)) . '\',\'' . $span_id . '\');">' . $o . '</a>';
             $t = '<span id="' . $span_id . '">' . $t . '</span>';
         }
         eval_js('translate_add_id("' . $span_id . '","' . Epesi::escapeJS($o) . '");');
         $data[] = array($org, $t);
     }
     $gb = $this->init_module('Utils/GenericBrowser', null, 'lang_translations');
     $gb->set_custom_label($trans_filter);
     $gb->set_table_columns(array(array('name' => __('Original'), 'order_preg' => '/^<[^>]+>([^<]*)<[^>]+>$/i', 'search' => 'original'), array('name' => __('Translated'), 'search' => 'translated')));
     //$limit = $gb->get_limit(count($data));
     $id = 0;
     foreach ($data as $v) {
         //if ($id>=$limit['offset'] && $id<$limit['offset']+$limit['numrows'])
         $gb->add_row_array($v);
         $id++;
     }
     Base_LangCommon::load();
     $this->display_module($gb, array(true), 'automatic_display');
     Utils_ShortcutCommon::add(array(' '), 'translate_first_on_the_list', array('disable_in_input' => 1));
 }
Exemplo n.º 6
0
 public function body($arg = null)
 {
     load_js($this->get_module_dir() . 'calendar-jq.js');
     if (isset($this->tb)) {
         $this->display_module($this->tb);
         $this->tb->tag();
     } else {
         $kk = array_keys($this->settings['views']);
         $v = $this->settings['views'][$kk[0]];
         if (!in_array($v, self::$views)) {
             trigger_error('Invalid view: ' . $v . ' - ' . print_r(self::$views, true), E_USER_ERROR);
         }
         call_user_func(array($this, strtolower($v)));
     }
     if ($this->custom_new_event_href_js !== null) {
         $jshref = call_user_func($this->custom_new_event_href_js, $this->date + time() - strtotime(date('Y-m-d')), '0', '');
     } else {
         $jshref = $this->create_unique_href_js(array('action' => 'add', 'time' => $this->date + time() - strtotime(date('Y-m-d'))));
     }
     if ($jshref !== false) {
         $href = ' href="javascript:void(0)" onClick="' . str_replace('"', '\'', $jshref) . '" ';
         // TODO: regular escape didn't work
         Base_ActionBarCommon::add('add', __('Add event'), $href);
         Utils_ShortcutCommon::add(array('Ctrl', 'N'), 'function(){' . $jshref . '}');
     }
 }