function toHtml() { if(count($this->_cd)>1) { load_js('modules/Utils/CommonData/qf.js'); $id=$this->getAttribute('id'); if(!isset($id)) { $id = $this->getName(); $this->updateAttributes(array('id'=>$id)); } $val = $this->getValue(); $val = $val[0]; if($this->_flagFrozen) { eval_js('new Utils_CommonData_freeze(\''.Epesi::escapeJS($id,false).'\', \''.Epesi::escapeJS(json_encode($this->_cd),false).'\')'); $html = '<span id="'.$id.'_label"> </span>'; $name = $this->getPrivateName(); // Only use id attribute if doing single hidden input $html .= '<input' . $this->_getAttrString(array( 'type' => 'hidden', 'name' => $name, 'value' => $val, 'id' => $id )) . ' />'; return $html; } eval_js('new Utils_CommonData(\''.Epesi::escapeJS($id,false).'\', \''.Epesi::escapeJS($val,false).'\', \''.Epesi::escapeJS(json_encode($this->_cd),false).'\', '.($this->_add_empty_fields?1:0).')'); } return parent::toHtml(); }
function toHtml() { $str = ""; if ($this->_flagFrozen) { $str .= $this->getFrozenHtml(); } else { $value = $this->getAttribute('value'); if (is_numeric($value)) { $value = date('Y-m-d', $value); } $id = $this->getAttribute('id'); $name = $this->getAttribute('name'); if ($value) { $this->setAttribute('value', Base_RegionalSettingsCommon::time2reg($value, false, true, false)); } if (!isset($id)) { $id = 'datepicker_field_' . $name; $this->updateAttributes(array('id' => $id)); } $ex_date = Base_RegionalSettingsCommon::time2reg(null, false, true, false); $date_format = Base_RegionalSettingsCommon::date_format(); $this->setType('text'); if (!$this->getAttribute('placeholder')) { $this->setAttribute('placeholder', __('Click to select date')); } $js = Utils_PopupCalendarCommon::create_href(md5($id), 'new Ajax.Request(\'modules/Utils/PopupCalendar/up.php\',' . '{method:\'post\', parameters:{date: __YEAR__+\'-\'+__MONTH__+\'-\'+__DAY__},' . 'onSuccess:function(t){e=$(\'' . Epesi::escapeJS($id, false) . '\');if(e) {e.value=t.responseText;jq(e).change();}}})', null, null, 'popup.clonePosition(\'' . $id . '\',{setWidth:false,setHeight:false,offsetTop:$(\'' . $id . '\').getHeight()})', $value, $id); $str .= $this->_getTabs() . '<input ' . $js . ' ' . $this->_getAttrString($this->_attributes) . ' ' . Utils_TooltipCommon::open_tag_attrs(__('Example date: %s', array($ex_date)), false) . ' />'; eval_js('Event.observe(\'' . $id . '\',\'keypress\',Utils_PopupCalendarDatePicker.validate.bindAsEventListener(Utils_PopupCalendarDatePicker,\'' . Epesi::escapeJS($date_format, false) . '\'))'); eval_js('Event.observe(\'' . $id . '\',\'blur\',Utils_PopupCalendarDatePicker.validate_blur.bindAsEventListener(Utils_PopupCalendarDatePicker,\'' . Epesi::escapeJS($date_format, false) . '\'))'); } return $str; }
public static function init_tooltip_div(){ if(!isset($_SESSION['client']['utils_tooltip']['div_exists'])) { $smarty = Base_ThemeCommon::init_smarty(); $smarty->assign('tip','<span id="tooltip_text"></span>'); ob_start(); @Base_ThemeCommon::display_smarty($smarty,'Utils_Tooltip'); $tip_th = ob_get_clean(); eval_js('Utils_Tooltip__create_block(\''.Epesi::escapeJS($tip_th,false).'\')',false); $_SESSION['client']['utils_tooltip']['div_exists'] = true; } on_exit(array('Utils_TooltipCommon', 'hide_tooltip'),null,false); }
public static function QFfield_account_name(&$form, $field, $label, $mode, $default, $desc, $rb = null) { $form->addElement('text', $field, $label, array('id' => $field)); $form->registerRule($field, 'function', 'check_account_name', 'CRM_RoundcubeCommon'); $form->addRule($field, __('Account Name already in use'), $field, isset($rb->record['id']) ? $rb->record['id'] : null); $form->setDefaults(array($field => $default)); load_js('modules/CRM/Roundcube/utils.js'); eval_js('CRM_RC.filled_smtp_message=\'' . Epesi::escapeJS(__('SMTP login and password was filled with imap account details. Please change them if needed.'), false, true) . '\';CRM_RC.edit_form()'); if ($mode == 'view') { $form->freeze(array($field)); } }
public static function create_href($name, $function = '', $mode = null, $first_day_of_week = null, $pos_js = null, $default = null, $id = null) { Base_ThemeCommon::load_css('Utils_PopupCalendar'); load_js('modules/Utils/PopupCalendar/js/main2.js'); load_js('modules/Utils/PopupCalendar/datepicker.js'); if (!isset($mode)) { $mode = 'day'; } if (!isset($first_day_of_week)) { if (Acl::is_user()) { $first_day_of_week = self::get_first_day_of_week(); } else { $first_day_of_week = 0; } } elseif (!is_numeric($first_day_of_week)) { trigger_error('Invalid first day of week', E_USER_ERROR); } $calendar = '<div id="Utils_PopupCalendar">' . '<table cellspacing="0" cellpadding="0" border="0"><tr><td id="datepicker_' . $name . '_header">error</td></tr>' . '<tr><td id="datepicker_' . $name . '_view">calendar not loaded</td></tr></table></div>'; $entry = 'datepicker_' . $name . '_calendar'; $butt = $id === null ? 'datepicker_' . $name . '_button' : $id; $smarty = Base_ThemeCommon::init_smarty(); $smarty->assign('calendar', $calendar); ob_start(); Base_ThemeCommon::display_smarty($smarty, 'Utils_PopupCalendar'); $cal_out = ob_get_clean(); print '<div id="' . $entry . '" class="utils_popupcalendar_popup" style="display:none;z-index:2050;width:1px;">' . $cal_out . '</div>'; if (!isset($pos_js)) { $pos_js = 'popup.clonePosition(\'' . $butt . '\',{setWidth:false,setHeight:false,offsetTop:$(\'' . $butt . '\').getHeight()});'; } eval_js('if(Epesi.ie)$(\'' . $entry . '\').style.position="fixed";else $(\'' . $entry . '\').absolutize();'); $ret = 'onClick="var popup=$(\'' . $entry . '\');' . $pos_js . ';$(\'' . $entry . '\').toggle()" href="javascript:void(0)" id="' . $butt . '"'; $function .= ';$(\'' . $entry . '\').hide()'; if ($default) { if (!is_numeric($default)) { $default = strtotime($default); } $args = date('Y', $default) . ',' . (date('n', $default) - 1) . ',' . date('d', $default); } else { $args = ''; } $js = 'var datepicker_' . $name . ' = new Utils_PopupCalendar("' . Epesi::escapeJS($function, true, false) . '", \'' . $name . '\',\'' . $mode . '\',\'' . $first_day_of_week . '\','; $months = array(__('January'), __('February'), __('March'), __('April'), __('May'), __('June'), __('July'), __('August'), __('September'), __('October'), __('November'), __('December')); $days = array(__('Sun'), __('Mon'), __('Tue'), __('Wed'), __('Thu'), __('Fri'), __('Sat')); $js .= 'new Array(\'' . implode('\',\'', $months) . '\'),'; $js .= 'new Array(\'' . implode('\',\'', $days) . '\')'; $js .= ');' . 'datepicker_' . $name . '.show(' . $args . ')'; eval_js($js); // eval_js('$(\''.$entry.'\').absolutize();'); return $ret; }
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(); }
public function applet($values, &$opts) { //available applet options: toggle,href,title,go,go_function,go_arguments,go_contruct_arguments Base_ThemeCommon::load_css('Applets_Weather'); $opts['title'] = __('Weather'); $rssfeed = $values['rssfeed'] . '?p=' . $values['zipcode'] . '&u=' . $values['temperature']; $name = md5($this->get_path() . $rssfeed); //div for updating print '<div id="Applets_Weather"><div id="rssfeed_' . $name . '"><span>' . __('Loading Weather...') . '</span></div></div>'; //interval execution eval_js_once('var rssfeedcache = Array();' . 'rssfeedfunc = function(name,fee,num,cache){' . 'if(!$(\'rssfeed_\'+name)) return;' . 'if(cache && typeof rssfeedcache[name] != \'undefined\')' . '$(\'rssfeed_\'+name).innerHTML = rssfeedcache[name];' . 'else ' . 'new Ajax.Updater(\'rssfeed_\'+name,\'modules/Applets/Weather/refresh.php\',{' . 'method:\'post\',' . 'onComplete:function(r){rssfeedcache[name]=r.responseText},' . 'parameters:{feed:fee, number:num, cid: Epesi.client_id}});' . '}'); eval_js_once('setInterval(\'rssfeedfunc(\\\'' . $name . '\\\',\\\'' . Epesi::escapeJS($rssfeed, false) . '\\\' , 2 , 0)\',1799993)'); //29 minutes and 53 seconds //get rss now! eval_js('rssfeedfunc(\'' . $name . '\',\'' . Epesi::escapeJS($rssfeed, false) . '\' , 2 , 1)'); }
public function applet($values, &$opts) { //available applet options: toggle,href,title,go,go_function,go_arguments,go_contruct_arguments if (!$values['title']) { $values['title'] = __('RSS Feed'); } $opts['title'] = $values['title']; $name = md5($this->get_path() . $values['rssfeed']); //div for updating print '<div id="rssfeed_' . $name . '" style="width: 270px; padding: 5px 5px 5px 20px;">' . __('Loading RSS...') . '</div>'; //interval execution eval_js_once('var rssfeedcache = Array();' . 'rssfeedfunc = function(name,fee,num,cache){' . 'if(!$(\'rssfeed_\'+name)) return;' . 'if(cache && typeof rssfeedcache[name] != \'undefined\')' . '$(\'rssfeed_\'+name).innerHTML = rssfeedcache[name];' . 'else ' . 'new Ajax.Updater(\'rssfeed_\'+name,\'modules/Applets/RssFeed/refresh.php\',{' . 'method:\'post\',' . 'onComplete:function(r){rssfeedcache[name]=r.responseText},' . 'parameters:{feed:fee, number:num, cid: Epesi.client_id}});' . '}'); eval_js_once('setInterval(\'rssfeedfunc(\\\'' . $name . '\\\',\\\'' . Epesi::escapeJS($values['rssfeed'], false) . '\\\' ,' . $values['rssnumber'] . ' , 0)\',1799993)'); //29 minutes and 53 seconds //get rss now! eval_js('rssfeedfunc(\'' . $name . '\',\'' . Epesi::escapeJS($values['rssfeed'], false) . '\' ,' . $values['rssnumber'] . ' , 1)'); }
function toHtml() { $str = ""; if ($this->_flagFrozen) { $str .= $this->getFrozenHtml(); } else { $id = $this->getAttribute('id'); $name = $this->getAttribute('name'); if(!isset($id)) { $id = 'currency_field_'.$name; $this->updateAttributes(array('id'=>$id)); } $this->dec_digits = DB::GetOne('SELECT MAX(decimals) FROM utils_currency'); $str .= $this->_getTabs() . '<div style="position: relative;">'; $str .= $this->_getTabs() . '<div style="margin-right:45px;" class="currency_amount"><input ' . $this->_getAttrString($this->_attributes) . ' '. Utils_TooltipCommon::open_tag_attrs(__('Example value: %s',array('123'.Utils_CurrencyFieldCommon::get_decimal_point().implode('',range(4,3+$this->dec_digits)))), false ). ' /></div>'; $str .= $this->_getTabs() . '<div style="margin-right:5px; width:40px; position:absolute;top:0px;right:0px;"><select style="width:40px;" name="__'.str_replace(array('[',']'),'',$name).'__currency" id="__'.$id.'__currency">'; $curs = DB::GetAll('SELECT id, symbol, active FROM utils_currency ORDER BY code'); foreach ($curs as $v) { if ($v['id']!=$this->currency && !$v['active']) continue; $str .= '<option value="'.$v['id'].'"'; if ($v['id']==$this->currency) $str .= ' selected="1"'; $str .= '>'.$v['symbol'].'</option>'; } $str .= '</select></div>'; $str .= $this->_getTabs() . '</div>'; load_js('modules/Utils/CurrencyField/currency.js'); $curr_format = '-?([0-9]*)\\'.Utils_CurrencyFieldCommon::get_decimal_point().'?[0-9]{0,'.$this->dec_digits.'}'; eval_js('Event.observe(\''.$id.'\',\'keypress\',Utils_CurrencyField.validate.bindAsEventListener(Utils_CurrencyField,\''.Epesi::escapeJS($curr_format,false).'\'))'); eval_js('Event.observe(\''.$id.'\',\'blur\',Utils_CurrencyField.validate_blur.bindAsEventListener(Utils_CurrencyField,\''.Epesi::escapeJS($curr_format,false).'\'))'); } return $str; } //end func toHtml
public static function post_install_refresh_by_ajax() { $show_processing = "Epesi.procOn++;Epesi.updateIndicatorText('" . Epesi::escapeJS(__('Running post download procedures')) . "');Epesi.updateIndicator();"; $success_text = Epesi::escapeJS(__("Success. Restart EPESI to ensure proper operation.")); $failure_text = Epesi::escapeJS(__("Patch apply error. See patches log for more information (EPESI_DIR/data/logs/patches.log)")); $ajax_req = "new Ajax.Request('modules/Base/EpesiStore/runpatches.php'," . "{ method: 'post', " . "onComplete: function(t) {Epesi.procOn--;" . "if (t.responseText == '1') statusbar_message('<div class=\"message normal\">" . $success_text . "</div>');" . "else if (t.responseText == '0') alert('{$failure_text}');" . "else alert('Error: '+t.responseText);" . "Epesi.updateIndicator();" . "}});"; eval_js($show_processing . $ajax_req); }
$results[$i] = array(); $i--; $words[$i] = strtolower($words[$i]); } foreach ($helps as $m => $tutorials) { foreach ($tutorials as $tut) { $match = 0; $l = strtolower($tut['label']); foreach ($words as $w) { if (strpos($l, $w) !== false) { $match++; } } $l = strtolower($tut['keywords']); foreach ($words as $w) { if (strpos($l, $w) !== false) { $match++; } } if ($match) { $results[$match][] = $tut; } } } foreach ($results as $count => $tutorials) { foreach ($tutorials as $tut) { $html .= '<a href="javascript:void(0);" onclick="Helper.start_tutorial(\'' . Epesi::escapeJS(trim($tut['steps'], '#')) . '\')">' . $tut['label'] . '</a>'; } } print '$("Base_Help__help_links").innerHTML = "' . Epesi::escapeJS($html) . '";';
/** * @author Arkadiusz Bisaga <*****@*****.**> * @copyright Copyright © 2008, Telaxus LLC * @license MIT * @version 1.0 * @package epesi-utils * @subpackage watchdog */ if (!isset($_POST['id']) || !isset($_POST['state']) || !isset($_POST['element']) || !isset($_POST['cat']) || !isset($_POST['cid'])) { die('Invalid request: ' . print_r($_POST, true)); } define('JS_OUTPUT', 1); define('CID', $_POST['cid']); define('READ_ONLY_SESSION', true); require_once '../../../include.php'; ModuleManager::load_modules(); $id = json_decode($_POST['id']); $cat = json_decode($_POST['cat']); $state = json_decode($_POST['state']); $element = json_decode($_POST['element']); if (!Acl::is_user()) { die('alert("Unauthorized access");'); } if ($state) { Utils_WatchdogCommon::subscribe($cat, $id); } else { Utils_WatchdogCommon::unsubscribe($cat, $id); } print 'jq("#' . $element . '").html("' . Epesi::escapeJS(Utils_WatchdogCommon::get_change_subscription_icon_tags($cat, $id)) . '");';
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)); }
/** * Displays the table. * * @param string template file that should be used to display the table, use Base_ThemeCommon::get_template_filename() for proper filename * @param bool enabling paging, true by default */ public function body($template=null,$paging=true){ if(!$this->columns) trigger_error('columns array empty, please call set_table_columns',E_USER_ERROR); $md5_id = md5($this->get_path()); $this->set_module_variable('first_display','done'); $theme = $this->init_module('Base/Theme'); $per_page = $this->get_module_variable('per_page'); $order = $this->get_module_variable('order'); $this->expandable = $this->get_module_variable('expandable',$this->expandable); $expand_action_only = false; if ($this->expandable) { if(!$this->en_actions) { $expand_action_only = true; $this->en_actions = true; } } if ($this->en_actions) $actions_position = Base_User_SettingsCommon::get('Utils/GenericBrowser','actions_position'); $ch_adv_search = $this->get_unique_href_variable('adv_search'); if (isset($ch_adv_search)) { $this->set_module_variable('adv_search',$ch_adv_search); $this->set_module_variable('search',array()); location(array()); } $search = $this->get_module_variable('search'); $renderer = new HTML_QuickForm_Renderer_TCMSArraySmarty(); $form_p = $this->init_module('Libs/QuickForm'); $pager_on = false; if(isset($this->rows_qty) && $paging) { if(!$this->forced_per_page) { $form_p->addElement('select','per_page',__('Number of rows per page'), Utils_GenericBrowserCommon::$possible_vals_for_per_page, 'onChange="'.$form_p->get_submit_form_js(false).'"'); $form_p->setDefaults(array('per_page'=>$per_page)); } $qty_pages = ceil($this->rows_qty/$this->per_page); if ($qty_pages<=25) { $pages = array(); if($this->rows_qty==0) $pages[0] = 1; else foreach (range(1, $qty_pages) as $v) $pages[$v] = $v; $form_p->addElement('select','page',__('Page'), $pages, 'onChange="'.$form_p->get_submit_form_js(false).'"'); $form_p->setDefaults(array('page'=>(int)(ceil($this->offset/$this->per_page)+1))); } else { $form_p->addElement('text','page',__('Page (%s to %s)', array(1,$qty_pages)), array('onclick'=>'this.focus();this.select();', 'onChange'=>$form_p->get_submit_form_js(false), 'style'=>'width:'.(7*strlen($qty_pages)).'px;')); $form_p->setDefaults(array('page'=>(int)(ceil($this->offset/$this->per_page)+1))); } $pager_on = true; } $search_on=false; if(!$this->is_adv_search_on()) { foreach($this->columns as $k=>$v) if (isset($v['search'])) { $this->form_s->addElement('text','search',__('Keyword'), array('id'=>'gb_search_field', 'placeholder'=>__('search keyword...'), 'x-webkit-speech'=>'x-webkit-speech', 'lang'=>Base_LangCommon::get_lang_code(), 'onwebkitspeechchange'=>$this->form_s->get_submit_form_js())); $this->form_s->setDefaults(array('search'=>isset($search['__keyword__'])?$search['__keyword__']:'')); $search_on=true; break; } } else { $search_fields = array(); if ($this->en_actions && $actions_position==0) $mov = 1; else $mov=0; foreach($this->columns as $k=>$v) { if(isset($v['display']) && !$v['display']) { $mov--; continue; } if (isset($v['search'])) { $this->form_s->addElement('hidden','search__'.$v['search'],''); $default = isset($search[$v['search']])?$search[$v['search']]:''; $this->form_s->setDefaults(array('search__'.$v['search']=>$default)); $in = '<input value="'.$default.'" x-webkit-speech="x-webkit-speech" lang="'.Base_LangCommon::get_lang_code().'" name="search__textbox_'.$v['search'].'" placeholder="'.__('search keyword...').'" onblur="document.forms[\''.$this->form_s->getAttribute('name').'\'].search__'.$v['search'].'.value = this.value;" onkeydown="if (event.keyCode==13) {document.forms[\''.$this->form_s->getAttribute('name').'\'].search__'.$v['search'].'.value = this.value;'.$this->form_s->get_submit_form_js().';}" />'; $search_fields[$k+$mov] = $in; $search_on=true; } } $theme->assign('search_fields', $search_fields); } if ($search_on) { $this->form_s->addElement('submit','submit_search',__('Search'), array('id'=>'gb_search_button')); if (Base_User_SettingsCommon::get($this->get_type(), 'show_all_button')) { $el = $this->form_s->addElement('hidden','show_all_pressed'); $this->form_s->addElement('button','show_all',__('Show all'), array('onclick'=>'document.forms["'.$this->form_s->getAttribute('name').'"].show_all_pressed.value="1";'.$this->form_s->get_submit_form_js())); $el->setValue('0'); } } if ($pager_on) { $form_p->accept($renderer); $form_array = $renderer->toArray(); $theme->assign('form_data_paging', $form_array); $theme->assign('form_name_paging', $form_p->getAttribute('name')); // form processing if($form_p->validate()) { $values = $form_p->exportValues(); if(isset($values['per_page'])) { $this->set_module_variable('per_page',$values['per_page']); Base_User_SettingsCommon::save('Utils/GenericBrowser','per_page',$values['per_page']); } if(isset($values['page']) && is_numeric($values['page']) && ($values['page']>=1 && $values['page']<=$qty_pages)) { $this->set_module_variable('offset',($values['page']-1)*$this->per_page); } location(array()); return; } } if ($search_on) { $this->form_s->accept($renderer); $form_array = $renderer->toArray(); $theme->assign('form_data_search', $form_array); $theme->assign('form_name_search', $this->form_s->getAttribute('name')); // form processing if($this->form_s->validate()) { $values = $this->form_s->exportValues(); if (isset($values['show_all_pressed']) && $values['show_all_pressed']) { $this->set_module_variable('search',array()); $this->set_module_variable('show_all_triggered',true); location(array()); return; } $search = array(); foreach ($values as $k=>$v){ if ($k=='search') { if ($v!=__('search keyword...') && $v!='') $search['__keyword__'] = $v; break; } if (substr($k,0,8)=='search__') { $val = substr($k,8); if ($v!=__('search keyword...') && $v!='') $search[$val] = $v; } } $this->set_module_variable('search',$search); location(array()); return; } } $headers = array(); if ($this->en_actions) { $max_actions = 0; // Possibly improve it to calculate it during adding actions foreach($this->actions as $i=>$v) { $this_width = 0; foreach ($v as $vv) { $this_width += $vv['size']; } if ($this_width>$max_actions) $max_actions = $this_width; } if ($actions_position==0) $headers[-1] = array('label'=>'<span>'.' '.'</span>','attrs'=>'style="width: '.($max_actions*16+6).'px;" class="Utils_GenericBrowser__actions"'); else $headers[count($this->columns)] = array('label'=>'<span>'.' '.'</span>','attrs'=>'style="width: '.($max_actions*16+6).'px;" class="Utils_GenericBrowser__actions"'); } $all_width = 0; foreach($this->columns as $k=>$v) { if (!isset($this->columns[$k]['width'])) $this->columns[$k]['width'] = 100; if (!is_numeric($this->columns[$k]['width'])) continue; $all_width += $this->columns[$k]['width']; if (isset($v['quickjump'])) { $quickjump = $this->set_module_variable('quickjump',$v['quickjump']); $quickjump_col = $k; } } $i = 0; $is_order = false; $adv_history = Base_User_SettingsCommon::get('Utils/GenericBrowser','adv_history'); foreach($this->columns as $v) { if (array_key_exists('display', $v) && $v['display']==false) { $i++; continue; } if(isset($v['order'])) $is_order = true; if(!isset($headers[$i])) $headers[$i] = array('label'=>''); if (!$adv_history && $v['name'] && $v['name']==$order[0]['column']) $label = '<span style="padding-right: 12px; margin-right: 12px; background-image: url('.Base_ThemeCommon::get_template_file('Utils_GenericBrowser','sort-'.strtolower($order[0]['direction']).'ending.png').'); background-repeat: no-repeat; background-position: right;">'.$v['name'].'</span>'; else $label = $v['name']; $headers[$i]['label'] .= (isset($v['preppend'])?$v['preppend']:'').(isset($v['order'])?'<a '.$this->create_unique_href(array('change_order'=>$v['name'])).'>' . $label . '</a>':$label).(isset($v['append'])?$v['append']:''); //if ($v['search']) $headers[$i] .= $form_array['search__'.$v['search']]['label'].$form_array['search__'.$v['search']]['html']; if ($this->absolute_width) { $headers[$i]['attrs'] = 'width="'.$v['width'].'" '; } elseif (!is_numeric($v['width'])) { $headers[$i]['attrs'] = 'style="width:'.$v['width'].'" '; } else { $headers[$i]['attrs'] = 'width="'.intval(100*$v['width']/$all_width).'%" '; } $headers[$i]['attrs'] .= 'nowrap="1" '; if (isset($v['attrs'])) $headers[$i]['attrs'] .= $v['attrs'].' '; $i++; } ksort($headers); $out_headers = array_values($headers); unset($headers); $out_data = array(); if($this->expandable) { eval_js_once('gb_expandable["'.$md5_id.'"] = {};'); eval_js_once('gb_expanded["'.$md5_id.'"] = 0;'); eval_js_once('gb_expand_icon = "'.Base_ThemeCommon::get_template_file('Utils/GenericBrowser', 'expand.gif').'";'); eval_js_once('gb_collapse_icon = "'.Base_ThemeCommon::get_template_file('Utils/GenericBrowser', 'collapse.gif').'";'); eval_js_once('gb_expand_icon_off = "'.Base_ThemeCommon::get_template_file('Utils/GenericBrowser', 'expand_gray.gif').'";'); eval_js_once('gb_collapse_icon_off = "'.Base_ThemeCommon::get_template_file('Utils/GenericBrowser', 'collapse_gray.gif').'";'); } foreach($this->rows as $i=>$r) { $col = array(); if($this->expandable) { $row_id = $md5_id.'_'.$i; $this->__add_row_action($i,'style="display:none;" href="javascript:void(0)" onClick="gb_expand(\''.$md5_id.'\',\''.$i.'\')" id="gb_more_'.$row_id.'"','Expand', null, Base_ThemeCommon::get_template_file('Utils/GenericBrowser', 'plus_gray.png'), 1001); $this->__add_row_action($i,'style="display:none;" href="javascript:void(0)" onClick="gb_collapse(\''.$md5_id.'\',\''.$i.'\')" id="gb_less_'.$row_id.'"','Collapse', null, Base_ThemeCommon::get_template_file('Utils/GenericBrowser', 'minus_gray.png'), 1001, false, 0); $this->__add_row_js($i,'gb_expandable_init("'.Epesi::escapeJS($md5_id,true,false).'","'.Epesi::escapeJS($i,true,false).'")'); if(!isset($this->row_attrs[$i])) $this->row_attrs[$i]=''; $this->row_attrs[$i] .= 'id="gb_row_'.$row_id.'"'; } if ($this->en_actions) { if ($actions_position==0) $column_no = -1; else $column_no = count($this->columns); $col[$column_no]['attrs'] = ''; if (!empty($this->actions[$i])) { uasort($this->actions[$i], array($this,'sort_actions')); $actions = ''; foreach($this->actions[$i] as $icon=>$arr) { $actions .= '<a '.Utils_TooltipCommon::open_tag_attrs($arr['tooltip']!==null?$arr['tooltip']:$arr['label'], $arr['tooltip']===null).' '.$arr['tag_attrs'].'>'; if ($icon=='view' || $icon=='delete' || $icon=='edit' || $icon=='info' || $icon=='restore' || $icon=='append data' || $icon=='active-on' || $icon=='active-off' || $icon=='history' || $icon=='move-down' || $icon=='move-up' || $icon=='history_inactive' || $icon=='print' || $icon == 'move-up-down') { $actions .= '<img class="action_button" src="'.Base_ThemeCommon::get_template_file('Utils/GenericBrowser',$icon.($arr['off']?'-off':'').'.png').'" border="0">'; } elseif(file_exists($icon)) { $actions .= '<img class="action_button" src="'.$icon.'" border="0">'; } else { $actions .= $arr['label']; } $actions .= '</a>'; } $col[$column_no]['label'] = $actions; $col[$column_no]['attrs'] .= ' class="Utils_GenericBrowser__actions Utils_GenericBrowser__td"'; // Add overflow_box to actions $settings = Base_User_SettingsCommon::get('Utils_GenericBrowser', 'zoom_actions'); if ($settings==2 || ($settings==1 && detect_iphone())) $col[$column_no]['attrs'] .= ' onmouseover="if(typeof(table_overflow_show)!=\'undefined\')table_overflow_show(this,true);"'; } else { $col[$column_no]['label'] = ' '; $col[$column_no]['attrs'] .= 'nowrap="nowrap"'.' class="Utils_GenericBrowser__td"'; } if (isset($this->no_actions[$i])) $col[$column_no]['attrs'] .= ' style="display:none;"'; } foreach($r as $k=>$v) { if (is_array($v) && isset($v['dummy'])) $v['style'] = 'display:none;'; if (array_key_exists('display',$this->columns[$k]) && $this->columns[$k]['display']==false) continue; if (is_array($v) && isset($v['attrs'])) $col[$k]['attrs'] = $v['attrs']; else $col[$k]['attrs'] = ''; if ($this->absolute_width) $col[$k]['attrs'] .= ' width="'.$this->columns[$k]['width'].'"'; if (!is_array($v)) $v = array('value'=>$v); $col[$k]['label'] = $v['value']; if (!isset($v['overflow_box']) || $v['overflow_box']) { $col[$k]['attrs'] .= ' onmouseover="if(typeof(table_overflow_show)!=\'undefined\')table_overflow_show(this);"'; } else { if (!isset($v['style'])) $v['style'] = ''; $v['style'] .= 'white-space: normal;'; } $col[$k]['attrs'] .= ' class="Utils_GenericBrowser__td '.(isset($v['class'])?$v['class']:'').'"'; $col[$k]['attrs'] .= isset($v['style'])? ' style="'.$v['style'].'"':''; if (isset($quickjump_col) && $k==$quickjump_col) $col[$k]['attrs'] .= ' class="Utils_GenericBrowser__quickjump"'; if ((!isset($this->columns[$k]['wrapmode']) || $this->columns[$k]['wrapmode']!='cut') && isset($v['hint'])) $col[$k]['attrs'] .= ' title="'.$v['hint'].'"'; $col[$k]['attrs'] .= (isset($this->columns[$k]['wrapmode']) && $this->columns[$k]['wrapmode']=='nowrap')?' nowrap':''; if ($all_width!=0) $max_width = 130*$this->columns[$k]['width']/$all_width*(7+(isset($this->columns[$k]['fontsize'])?$this->columns[$k]['fontsize']:0)); else $max_width = 0; if (isset($this->columns[$k]['wrapmode']) && $this->columns[$k]['wrapmode']=='cut'){ if (strlen($col[$k]['label'])>$max_width){ if (is_array($v) && isset($v['hint'])) $col[$k]['attrs'] .= ' title="'.$col[$k]['label'].': '.$v['hint'].'"'; else $col[$k]['attrs'] .= ' title="'.$col[$k]['label'].'"'; $col[$k]['label'] = substr($col[$k]['label'],0,$max_width-3).'...'; } elseif (is_array($v) && isset($v['hint'])) $col[$k]['attrs'] .= ' title="'.$v['hint'].'"'; $col[$k]['attrs'] .= ' nowrap'; } } ksort($col); $expanded = $this->expandable ? ' expanded' : ''; foreach($col as $v) $out_data[] = array('label'=>'<div class="expandable'.$expanded.'">'.$v['label'].'</div>','attrs'=>$v['attrs']); if(isset($this->rows_jses[$i])) eval_js($this->rows_jses[$i]); } if (isset($quickjump)) { $quickjump_to = $this->get_module_variable('quickjump_to'); $all = '<span class="all">'.__('All').'</span>'; if (isset($quickjump_to) && $quickjump_to != '') $all = '<a class="all" '.$this->create_unique_href(array('quickjump_to'=>'')).'>'.__('All').'</a>'; $letter_links = array(0 => $all); if ($quickjump_to != '0') $letter_links[] .= '<a class="all" '.$this->create_unique_href(array('quickjump_to'=>'0')).'>'.'123'.'</a>'; else $letter_links[] .= '<span class="all">' . '123' . '</span>'; $letter = 'A'; while ($letter<='Z') { if ($quickjump_to != $letter) $letter_links[] .= '<a class="letter" '.$this->create_unique_href(array('quickjump_to'=>$letter)).'>'.$letter.'</a>'; else $letter_links[] .= '<span class="letter">' . $letter . '</span>'; $letter = chr(ord($letter)+1); } $theme->assign('letter_links', $letter_links); $theme->assign('quickjump_to', $quickjump_to); } $theme->assign('data', $out_data); $theme->assign('cols', $out_headers); $theme->assign('row_attrs', $this->row_attrs); $theme->assign('table_id','table_'.$md5_id); if($expand_action_only) { eval_js('gb_expandable_hide_actions("'.$md5_id.'")'); } $theme->assign('table_prefix', $this->table_prefix); $theme->assign('table_postfix', $this->table_postfix); $theme->assign('summary', $this->summary()); $theme->assign('first', $this->gb_first()); $theme->assign('prev', $this->gb_prev()); $theme->assign('next', $this->gb_next()); $theme->assign('last', $this->gb_last()); $theme->assign('custom_label', $this->custom_label); $theme->assign('custom_label_args', $this->custom_label_args); if($this->expandable) { $theme->assign('expand_collapse',array( 'e_label'=>__('Expand All'), 'e_href'=>'href="javascript:void(0);" onClick=\'gb_expand_all("'.$md5_id.'")\'', 'e_id'=>'expand_all_button_'.$md5_id, 'c_label'=>__('Collapse All'), 'c_href'=>'href="javascript:void(0);" onClick=\'gb_collapse_all("'.$md5_id.'")\'', 'c_id'=>'collapse_all_button_'.$md5_id )); $max_actions = isset($max_actions) ? $max_actions : 0; eval_js('gb_expandable_adjust_action_column("'.$md5_id.'", ' . $max_actions . ')'); eval_js('gb_show_hide_buttons("'.$md5_id.'")'); } if ($search_on) $theme->assign('adv_search','<a id="switch_search_'.($this->is_adv_search_on()?'simple':'advanced').'" class="button" '.$this->create_unique_href(array('adv_search'=>!$this->is_adv_search_on())).'>' . ($this->is_adv_search_on()?__('Simple Search'):__('Advanced Search')) . ' <img src="' . Base_ThemeCommon::get_template_file($this -> get_type(), 'advanced.png') . '" width="8px" height="20px" border="0" style="vertical-align: middle;"></a>'); else $theme->assign('adv_search',''); if (Base_User_SettingsCommon::get('Utils/GenericBrowser','adv_history') && $is_order){ $theme->assign('reset', '<a '.$this->create_unique_href(array('action'=>'reset_order')).'>'.__('Reset Order').'</a>'); $theme->assign('order',$this->get_module_variable('order_history_display')); } $theme->assign('id',md5($this->get_path())); if ($this->resizable_columns) { load_js($this->get_module_dir().'js/col_resizable.js'); $fixed_col_setting = !empty($this->fixed_columns_selector)? ', skipColumnClass:"'.$this->fixed_columns_selector.'"':''; eval_js('jq("#table_'.$md5_id.'").colResizable({liveDrag:true, postbackSafe:true, partialRefresh:true'.$fixed_col_setting.'});'); } if(isset($template)) $theme->display($template,true); else $theme->display(); $this->set_module_variable('show_all_triggered',false); }
function escapeJS($str, $double = true, $single = true) { return Epesi::escapeJS($str, $double, $single); }
public static function create_write_to_link($uid) { $ret = Base_UserCommon::get_user_label($uid, true); if (Acl::get_user() != $uid) { $ret = "<a href=\"javascript:void(0);\" onclick=\"autoselect_add_value('shoutbox_to', " . $uid . ", '" . Epesi::escapeJS($ret) . "');autoselect_stop_searching('shoutbox_to');\$('shoutbox_to').onchange();\">" . $ret . '</a>'; } return $ret; }
public function month() { $theme = $this->pack_module('Base/Theme'); Base_ThemeCommon::load_css('Utils_Calendar', 'common'); $theme->assign('trash_label', __('Drag and drop to delete')); $theme->assign('nextyear_href', $this->create_unique_href(array('date'=>(date('Y',$this->date)+1).date('-m-d',$this->date)))); $theme->assign('nextyear_label',__('Next year')); $theme->assign('nextmonth_href', $this->create_unique_href(array('date'=>date('Y-m-d',$this->date+86400*date('t',$this->date))))); $theme->assign('nextmonth_label',__('Next month')); $theme->assign('today_href', $this->create_unique_href(array('date'=>date('Y-m-d')))); $theme->assign('today_label', __('Today')); $theme->assign('prevmonth_href', $this->create_unique_href(array('date'=>date('Y-m-d',$this->date-86400*date('t',$this->date-86400*(date('d', $this->date)+1)))))); $theme->assign('prevmonth_label', __('Previous month')); $theme->assign('prevyear_href', $this->create_unique_href(array('date'=>(date('Y',$this->date)-1).date('-m-d',$this->date)))); $theme->assign('prevyear_label', __('Previous year')); $theme->assign('info', __('Double click on cell to add event')); if ($this->isset_unique_href_variable('date')) $this->set_date($this->get_unique_href_variable('date')); $link_text = $this->create_unique_href_js(array('date'=>'__YEAR__-__MONTH__-__DAY__')); $theme->assign('popup_calendar', Utils_PopupCalendarCommon::show('week_selector', $link_text,'month')); $month = $this->month_array($this->date); $dnd = array(); foreach($month as & $week) { foreach($week['days'] as & $cday) { $cday['id'] = 'UCcell_'.$cday['time']; $dnd[] = $cday['time']; } } $day_headers = array(); $day = strtotime('Sun'); $day = strtotime('+'.Utils_PopupCalendarCommon::get_first_day_of_week().' days', $day); for ($i=0; $i<7; $i++) { $day_headers[] = array('class'=>(date('N',$day)>=6?'weekend_day_header':'day_header'), 'label'=>__date('D', $day)); $day = strtotime('+1 day', $day); } $theme->assign('month_view_label', __('Month calendar')); $theme->assign('day_headers', $day_headers); $theme->assign('month', $month); $theme->assign('month_label', __date('F', $this->date)); $theme->assign('year_label', date('Y', $this->date)); $theme->assign('year_link', $this->create_unique_href(array('time'=>$this->date, 'tab'=>'Year','action'=>'switch'))); $theme->assign('trash_id','UCtrash'); $navigation_bar_additions = ''; if (is_callable(array($this->event_module, 'get_navigation_bar_additions'))) { $event_module_instance = $this->init_module($this->event_module); $navigation_bar_additions = call_user_func(array($event_module_instance,'get_navigation_bar_additions'), '', ''); } $theme->assign('navigation_bar_additions', $navigation_bar_additions); $theme->display('month'); //data $start_t = date('Y-m-d',$month[0]['days'][0]['time']); //$start_t = Base_RegionalSettingsCommon::reg2time($start_t); $end_t = date('Y-m-d',$month[count($month)-1]['days'][6]['time']+86400); //$end_t = Base_RegionalSettingsCommon::reg2time($end_t); $ret = $this->get_events($start_t,$end_t); $this->displayed_events = array('start'=>$start_t, 'end'=>$end_t,'events'=>$ret); $this->js('Utils_Calendar.page_type=\'month\''); $ev_out = 'function() {'; foreach($ret as $ev) { $this->print_event($ev); if(!isset($ev['timeless']) || !$ev['timeless']) $ev_start = strtotime(Base_RegionalSettingsCommon::time2reg($ev['start'],true,true,true,false)); else $ev_start = strtotime($ev['timeless']); $ev_start = Base_RegionalSettingsCommon::reg2time(date('Y-m-d',$ev_start).' 00:00:00'); $dest_id = 'UCcell_'.$ev_start; $ev_out .= 'Utils_Calendar.add_event(\''.Epesi::escapeJS($dest_id,false).'\', \''.$ev['id'].'\', '.((!isset($ev['draggable']) || $ev['draggable']==true)?1:0).', 1);'; } $ev_out.='}'; $this->js('Utils_Calendar.add_events_f = '.$ev_out); $this->js('Utils_Calendar.add_events("Utils%2FCalendar%2Fmonth.css")'); if ($this->custom_new_event_href_js!==null) $jshref = call_user_func($this->custom_new_event_href_js, '__TIME__', '__TIMELESS__'); else $jshref = $this->create_unique_href_js(array('action'=>'add','time'=>'__TIME__','timeless'=>'__TIMELESS__')); eval_js('Utils_Calendar.activate_dnd(\''.Epesi::escapeJS(json_encode($dnd),false).'\','. '\''.Epesi::escapeJS($jshref,false).'\','. '\''.Epesi::escapeJS($this->get_path(),false).'\','. '\''.CID.'\')'); }
if (isset($ev['timeless'])) { $cc[1] = isset($ev['custom_row_key']) ? $ev['custom_row_key'] : 'timeless'; } else { $cc[0] = strtotime(Base_RegionalSettingsCommon::time2reg($cc[0], true, true, true, false)) + $ev['start'] - strtotime(Base_RegionalSettingsCommon::time2reg($ev['start'], false, true, true, false)); } // } else { //this code breaks calendar with interval less than 1 hour so commented this out // $cc[0] += $ev['start']-strtotime(date('Y-m-d H:00:00',$ev['start'])); } $ret = call_user_func_array(array($mod . 'Common', 'update'), array(&$ev_id, $cc[0], $ev['duration'], isset($cc[1]) ? $cc[1] : null)); if (!$ret) { print 'reject=true;'; exit; } //update content of event on page in client browser ob_start(); $ev = call_user_func(array($mod . 'Common', 'get'), $ev_id); $ret_ev = ob_get_clean(); if (!$ev) { exit; } if (isset($ev['title'])) { $ev = array($ev); } foreach ($ev as $e) { ob_start(); Utils_CalendarCommon::print_event($e, $_POST['page_type'] == 'day' ? 'day' : null, false); $ret = ob_get_clean(); print 'document.getElementById(\'utils_calendar_event:' . $ev_id . '\').innerHTML=\'' . Epesi::escapeJS($ret_ev . $ret, false) . '\';'; } exit; }
/** * For internal use only. */ public function browse($name='',$root=true){ if($this->is_back()) return false; $gb = $this->init_module('Utils/GenericBrowser',null,'browse'.md5($name)); $gb->set_table_columns(array( array('name'=>__('Key'),'width'=>20, 'order'=>'akey','search'=>1,'quickjump'=>'akey'), array('name'=>__('Value'),'width'=>20, 'order'=>'value','search'=>1) )); print('<h2>'.$name.'</h2><br>'); $ret = Utils_CommonDataCommon::get_translated_array($name,true,true); foreach($ret as $k=>$v) { $gb_row = $gb->get_new_row(); $gb_row->add_data($k,$v['value']); // ****** CommonData value translation $gb_row->add_action($this->create_callback_href(array($this,'browse'),array($name.'/'.$k,false)),'View'); if(!$v['readonly']) { $gb_row->add_action($this->create_callback_href(array($this,'edit'),array($name,$k)),'Edit'); $gb_row->add_action($this->create_confirm_callback_href(__('Delete array').' \''.Epesi::escapeJS($name.'/'.$k,false).'\'?',array('Utils_CommonData','remove_array'), array($name.'/'.$k)),'Delete'); } } //$this->display_module($gb); $this->display_module($gb,array(true),'automatic_display'); Base_ActionBarCommon::add('add',__('Add array'),$this->create_callback_href(array($this,'edit'),$name)); if(!$root) Base_ActionBarCommon::add('back',__('Back'),$this->create_back_href()); return true; }
$renderer = new HTML_QuickForm_Renderer_TCMSArraySmarty(); $form->accept($renderer); $data = $renderer->toArray(); $html = $data[$element]['html']; if ($form_name == '') { $html = '<form ' . $data['attributes'] . '>' . $html . '</form>'; } print '$("grid_value_field_' . $element . '_' . $id . '").innerHTML = \'' . Epesi::escapeJS($html) . '\';'; return; } ob_start(); $renderer = new HTML_QuickForm_Renderer_TCMSArraySmarty(); $form->accept($renderer); $data = $renderer->toArray(); $html = $data['__grid_' . $element]['error'] . $data['__grid_' . $element]['html']; if ($form_name == '') { $html = '<form ' . $data['attributes'] . '>' . $data['hidden'] . $html . '</form>'; $form_name = $form->get_name(); } $more_html .= ob_get_clean(); $html .= $more_html; print '$("grid_form_field_' . $element . '_' . $id . '").innerHTML = \'' . Epesi::escapeJS($html) . '\';'; print 'grid_edit_form_name = "' . $form_name . '";'; preg_match_all('/name=\\"([^\\"]+)\\"/', $data['__grid_' . $element]['html'], $matches); if (isset($matches[1][0])) { $v = $matches[1][0]; $js = 'el = document.getElementsByName("' . $v . '")[0];' . 'if(el){' . 'if(!el.id)el.id="grid_' . md5($v) . '";'; $js .= 'focus_by_id(el.id);' . '}'; print $js; } Epesi::send_output();
public function purge_log() { # Return to main body if ($this->is_back()) { return false; } $form = $this->init_module(Libs_QuickForm::module_name(), null, 'purge_date'); $form->addElement('header', null, __('Audit Log Maintenance')); $form->addElement('html', '<tr><td colspan=2><br />' . __('Purge log with records older than specified number of days:') . '</td></tr>'); $form->addElement('select', 'purge_date', __('Select number of days'), array(30 => 30, 90 => 90, 365 => 365, 1 => 'All')); $purge_date = $form->exportValue('purge_date'); $form->display(); if (!$purge_date == null) { $del_date = strtotime("-" . $purge_date . " days", time()); $sql_date = date('Y-m-d H:i:s', $del_date); # print ('<br/> date: '.$sql_date.'<br />'); if ($purge_date == 1) { $sql_query = 'Delete FROM base_login_audit'; $ret = DB::Execute($sql_query); print __('Entire log was purged!'); } else { $sql_query = 'Delete FROM base_login_audit where start_time < \'' . $sql_date . '\''; $ret = DB::Execute($sql_query); print __('Records older than %s days (%s) were purged.', array($purge_date, date('Y-m-d', $del_date))); } } Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href()); Base_ActionBarCommon::add('delete', __('Purge Log File'), 'href="javascript:void(0)" onClick="if(confirm(\'' . Epesi::escapeJS(__('Log will be purged!')) . '\')){' . $form->get_submit_form_js() . '}"'); return true; }
<?php if (!isset($_POST['cid']) || !is_numeric($_POST['cid'])) { die('Invalid request'); } define('CID', $_POST['cid']); define('READ_ONLY_SESSION', true); require_once '../../../include.php'; ModuleManager::load_modules(); $helps = ModuleManager::call_common_methods('help'); $html = ''; foreach ($helps as $m => $tutorials) { foreach ($tutorials as $tut) { if (!$tut['context']) { continue; } $html .= '<a href="javascript:void(0);" onclick="Helper.start_tutorial(\'' . Epesi::escapeJS(trim($tut['steps'], '#')) . '\')">' . $tut['label'] . '</a>'; } } print '$("Base_Help__help_suggestions").innerHTML = "' . Epesi::escapeJS($html) . '";';
public function view_field($action = 'add', $field = null) { if (!$action) $action = 'add'; if ($this->is_back()) return false; if ($this->check_for_jump()) return; $data_type = array( 'autonumber'=>__('Autonumber'), 'currency'=>__('Currency'), 'checkbox'=>__('Checkbox'), 'date'=>__('Date'), 'time' => __('Time'), 'timestamp' => __('Timestamp'), 'integer'=>__('Integer'), 'float'=>__('Float'), 'text'=>__('Text'), 'long text'=>__('Long text'), 'select'=>__('Select field') ); natcasesort($data_type); load_js('modules/Utils/RecordBrowser/js/field_admin.js'); $form = $this->init_module('Libs/QuickForm'); switch ($action) { case 'add': $form->addElement('header', null, __('Add new field')); break; case 'edit': $form->addElement('header', null, __('Edit field properties')); break; } $form->addElement('text', 'field', __('Field'), array('maxlength'=>32)); $form->registerRule('check_if_column_exists', 'callback', 'check_if_column_exists', $this); $this->current_field = $field; $form->registerRule('check_if_no_id', 'callback', 'check_if_no_id', $this); $form->addRule('field', __('Field required'), 'required'); $form->addRule('field', __('Field with this name already exists.'), 'check_if_column_exists'); $form->addRule('field', __('Field length cannot be over 32 characters.'), 'maxlength', 32); $form->addRule('field', __('Invalid field name.'), 'regex', '/^[a-zA-Z][a-zA-Z \(\)\%0-9]*$/'); $form->addRule('field', __('Invalid field name.'), 'check_if_no_id'); $form->addElement('text', 'caption', __('Caption'), array('maxlength'=>255, 'placeholder' => __('Leave empty to use default label'))); if ($action=='edit') { $row = DB::GetRow('SELECT field, caption, type, visible, required, param, filter, export, tooltip, extra, position FROM '.$this->tab.'_field WHERE field=%s',array($field)); switch ($row['type']) { case 'select': $row['select_data_type'] = 'select'; $row['select_type'] = 'select'; $row['data_source'] = 'rset'; $ref = explode(';', $row['param']); $refe = explode('::',$ref[0]); $row['rset'] = array_filter(explode(',',$refe[0])); $row['label_field'] = isset($refe[1]) ? str_replace('|', ',', $refe[1]) : ''; break; case 'multiselect': $row['select_data_type'] = 'select'; $row['select_type'] = 'multiselect'; $ref = explode(';', $row['param']); $refe = explode('::',$ref[0]); $tab = $refe[0]; if ($tab=='__COMMON__') { $row['data_source'] = 'commondata'; $order = isset($refe[2])?$refe[2]:'value'; $row['order_by'] = ($order=='key'?'key':'value'); $row['commondata_table'] = $refe[1]; } else { $row['label_field'] = ''; if (isset($refe[1])) $row['label_field'] = str_replace('|', ',', $refe[1]); $row['data_source'] = 'rset'; $row['rset'] = array_filter(explode(',',$tab)); } break; case 'commondata': $row['select_data_type'] = 'select'; $row['select_type'] = 'select'; $row['data_source'] = 'commondata'; $param = Utils_RecordBrowserCommon::decode_commondata_param($row['param']); $form->setDefaults(array('order_by'=>$param['order_by_key']?'key':'value', 'commondata_table'=>$param['array_id'])); break; case 'autonumber': $row['select_data_type'] = 'autonumber'; Utils_RecordBrowserCommon::decode_autonumber_param($row['param'], $autonumber_prefix, $autonumber_pad_length, $autonumber_pad_mask); $row['autonumber_prefix'] = $autonumber_prefix; $row['autonumber_pad_length'] = $autonumber_pad_length; $row['autonumber_pad_mask'] = $autonumber_pad_mask; break; case 'text': $row['select_data_type'] = $row['type']; $row['text_length'] = $row['param']; break; case 'time': case 'timestamp': $row['select_data_type'] = $row['type']; $row['minute_increment'] = $row['param']; break; default: $row['select_data_type'] = $row['type']; if (!isset($data_type[$row['type']])) $data_type[$row['type']] = _V(ucfirst($row['type'])); // ****** - field type } if (!isset($row['rset'])) $row['rset'] = array('contact'); if (!isset($row['data_source'])) $row['data_source'] = 'commondata'; $form->setDefaults($row); $selected_data = $row['type']; $this->admin_field_type = $row['select_data_type']; $this->admin_field = $row; } else { $selected_data = $form->exportValue('select_data_type'); $form->setDefaults(array('visible'=>1, 'autonumber_prefix'=>'#', 'autonumber_pad_length'=>'6', 'autonumber_pad_mask'=>'0')); } $this->admin_field_mode = $action; $this->admin_field_name = $field; $form->addElement('select', 'select_data_type', __('Data Type'), $data_type, array('id'=>'select_data_type', 'onchange'=>'RB_hide_form_fields()')); $form->addElement('text', 'text_length', __('Maximum Length'), array('id'=>'length')); $minute_increment_values = array(1=>1,2=>2,5=>5,10=>10,15=>15,20=>20,30=>30,60=>__('Full hours')); $form->addElement('select', 'minute_increment', __('Minutes Interval'), $minute_increment_values, array('id'=>'minute_increment')); $form->addElement('select', 'data_source', __('Source of Data'), array('rset'=>__('Recordset'), 'commondata'=>__('CommonData')), array('id'=>'data_source', 'onchange'=>'RB_hide_form_fields()')); $form->addElement('select', 'select_type', __('Type'), array('select'=>__('Single value selection'), 'multiselect'=>__('Multiple values selection')), array('id'=>'select_type')); $form->addElement('select', 'order_by', __('Order by'), array('key'=>__('Key'), 'value'=>__('Value')), array('id'=>'order_by')); $form->addElement('text', 'commondata_table', __('CommonData table'), array('id'=>'commondata_table')); $tables = Utils_RecordBrowserCommon::list_installed_recordsets(); asort($tables); $form->addElement('multiselect', 'rset', '<span id="rset_label">'.__('Recordset').'</span>', $tables, array('id'=>'rset')); $form->addElement('text', 'label_field', __('Related field(s)'), array('id'=>'label_field')); $form->addFormRule(array($this, 'check_field_definitions')); $form->addElement('checkbox', 'visible', __('Table view')); $form->addElement('checkbox', 'tooltip', __('Tooltip view')); $form->addElement('checkbox', 'required', __('Required'), null, array('id'=>'required')); $form->addElement('checkbox', 'filter', __('Filter enabled'), null, array('id' => 'filter')); $form->addElement('checkbox', 'export', __('Export')); $form->addElement('text', 'autonumber_prefix', __('Prefix string'), array('id' => 'autonumber_prefix')); $form->addRule('autonumber_prefix', __('Double underscore is not allowed'), 'callback', array('Utils_RecordBrowser', 'qf_rule_without_double_underscore')); $form->addElement('text', 'autonumber_pad_length', __('Pad length'), array('id' => 'autonumber_pad_length')); $form->addRule('autonumber_pad_length', __('Only integer numbers are allowed.'), 'regex', '/^[0-9]*$/'); $form->addElement('text', 'autonumber_pad_mask', __('Pad character'), array('id' => 'autonumber_pad_mask')); $form->addRule('autonumber_pad_mask', __('Double underscore is not allowed'), 'callback', array('Utils_RecordBrowser', 'qf_rule_without_double_underscore')); $form->addElement('checkbox', 'advanced', __('Edit advanced properties'), null, array('onchange'=>'RB_advanced_settings()', 'id'=>'advanced')); $form->addElement('text', 'display_callback', __('Value display function'), array('maxlength'=>255, 'style'=>'width:300px', 'id'=>'display_callback')); $form->addElement('text', 'QFfield_callback', __('Field generator function'), array('maxlength'=>255, 'style'=>'width:300px', 'id'=>'QFfield_callback')); if ($action=='edit') { $form->freeze('field'); $form->freeze('select_data_type'); $form->freeze('data_source'); $form->freeze('rset'); } if ($action=='edit') { $display_callbacback = DB::GetOne('SELECT callback FROM '.$this->tab.'_callback WHERE freezed=1 AND field=%s', array($field)); $QFfield_callbacback = DB::GetOne('SELECT callback FROM '.$this->tab.'_callback WHERE freezed=0 AND field=%s', array($field)); $form->setDefaults(array('display_callback'=>$display_callbacback)); $form->setDefaults(array('QFfield_callback'=>$QFfield_callbacback)); } if ($form->validate()) { $data = $form->exportValues(); $data['caption'] = trim($data['caption']); $data['field'] = trim($data['field']); $type = DB::GetOne('SELECT type FROM '.$this->tab.'_field WHERE field=%s', array($field)); if (!isset($data['select_data_type'])) $data['select_data_type'] = $type; if ($action=='add') $field = $data['field']; $id = preg_replace('/[^a-z0-9]/','_',strtolower($field)); $new_id = preg_replace('/[^a-z0-9]/','_',strtolower($data['field'])); if (preg_match('/^[a-z0-9_]*$/',$id)==0) trigger_error('Invalid column name: '.$field); if (preg_match('/^[a-z0-9_]*$/',$new_id)==0) trigger_error('Invalid new column name: '.$data['field']); $param = ''; switch ($data['select_data_type']) { case 'autonumber': $data['required'] = false; $data['filter'] = false; $param = Utils_RecordBrowserCommon::encode_autonumber_param( $data['autonumber_prefix'], $data['autonumber_pad_length'], $data['autonumber_pad_mask']); // delete field and add again later to generate values if ($action != 'add') { Utils_RecordBrowserCommon::delete_record_field($this->tab, $field); $action = 'add'; $field = $data['field']; } break; case 'checkbox': $data['required'] = false; break; case 'text': if ($action=='add') $param = $data['text_length']; else { if ($data['text_length']<$row['param']) trigger_error('Invalid field length', E_USER_ERROR); $param = $data['text_length']; if ($data['text_length']!=$row['param']) { if(DB::is_postgresql()) DB::Execute('ALTER TABLE '.$this->tab.'_data_1 ALTER COLUMN f_'.$id.' TYPE VARCHAR('.$param.')'); else DB::Execute('ALTER TABLE '.$this->tab.'_data_1 MODIFY f_'.$id.' VARCHAR('.$param.')'); } } break; case 'select': if ($data['data_source']=='commondata') { if ($data['select_type']=='select') { $param = Utils_RecordBrowserCommon::encode_commondata_param(array('order_by_key'=>$data['order_by']=='key', 'array_id'=>$data['commondata_table'])); $data['select_data_type'] = 'commondata'; } else { $param = '__COMMON__::'.$data['commondata_table'].'::'.$data['order_by']; $data['select_data_type'] = 'multiselect'; } } else { $data['select_data_type'] = $data['select_type']; if (!isset($row) || !isset($row['param'])) $row['param'] = ';::'; $props = explode(';', $row['param']); $change_param = false; if($data['rset']) { $fs = explode(',', $data['label_field']); if($data['label_field']) foreach($data['rset'] as $rset) { $ret = $this->detranslate_field_names($rset, $fs); if (!empty($ret)) trigger_error('Invalid fields: '.implode(',',$fs)); } $data['rset'] = implode(',',$data['rset']); $data['label_field'] = implode('|',$fs); $change_param = true; } else if ($action == 'add') { $data['rset'] = '__RECORDSETS__'; $data['label_field'] = ''; $change_param = true; } if ($change_param) { $props[0] = $data['rset'].'::'.$data['label_field']; $param = implode(';', $props); } else { $param = $row['param']; } } if (isset($row) && isset($row['type']) && $row['type']=='multiselect' && $data['select_type']=='select') { $ret = DB::Execute('SELECT id, f_'.$id.' AS v FROM '.$this->tab.'_data_1 WHERE f_'.$id.' IS NOT NULL'); while ($rr = $ret->FetchRow()) { $v = Utils_RecordBrowserCommon::decode_multi($rr['v']); $v = array_pop($v); DB::Execute('UPDATE '.$this->tab.'_data_1 SET f_'.$id.'=%s WHERE id=%d', array($v, $rr['id'])); } } if (isset($row) && isset($row['type']) && $row['type']!='multiselect' && $data['select_type']=='multiselect') { if(DB::is_postgresql()) DB::Execute('ALTER TABLE '.$this->tab.'_data_1 ALTER COLUMN f_'.$id.' TYPE TEXT'); else DB::Execute('ALTER TABLE '.$this->tab.'_data_1 MODIFY f_'.$id.' TEXT'); $ret = DB::Execute('SELECT id, f_'.$id.' AS v FROM '.$this->tab.'_data_1 WHERE f_'.$id.' IS NOT NULL'); while ($rr = $ret->FetchRow()) { $v = Utils_RecordBrowserCommon::encode_multi($rr['v']); DB::Execute('UPDATE '.$this->tab.'_data_1 SET f_'.$id.'=%s WHERE id=%d', array($v, $rr['id'])); } } break; case 'time': case 'timestamp': $param = $data['minute_increment']; break; default: if (isset($row) && isset($row['param'])) $param = $row['param']; break; } if ($action=='add') { $id = $new_id; if (in_array($data['select_data_type'], array('time','timestamp','currency','integer'))) $style = $data['select_data_type']; else $style = ''; $new_field_data = array('name' => $data['field'], 'type' => $data['select_data_type'], 'param' => $param, 'style' => $style); if (isset($this->admin_field['position']) && $this->admin_field['position']) { $new_field_data['position'] = (int) $this->admin_field['position']; } Utils_RecordBrowserCommon::new_record_field($this->tab, $new_field_data); } if(!isset($data['visible']) || $data['visible'] == '') $data['visible'] = 0; if(!isset($data['required']) || $data['required'] == '') $data['required'] = 0; if(!isset($data['filter']) || $data['filter'] == '') $data['filter'] = 0; if(!isset($data['export']) || $data['export'] == '') $data['export'] = 0; if(!isset($data['tooltip']) || $data['tooltip'] == '') $data['tooltip'] = 0; foreach($data as $key=>$val) if (is_string($val)) $data[$key] = htmlspecialchars($val); /* DB::StartTrans(); if ($id!=$new_id) { Utils_RecordBrowserCommon::check_table_name($this->tab); if(DB::is_postgresql()) DB::Execute('ALTER TABLE '.$this->tab.'_data_1 RENAME COLUMN f_'.$id.' TO f_'.$new_id); else { $old_param = DB::GetOne('SELECT param FROM '.$this->tab.'_field WHERE field=%s', array($field)); DB::RenameColumn($this->tab.'_data_1', 'f_'.$id, 'f_'.$new_id, Utils_RecordBrowserCommon::actual_db_type($type, $old_param)); } }*/ DB::Execute('UPDATE '.$this->tab.'_field SET caption=%s, param=%s, type=%s, field=%s, visible=%d, required=%d, filter=%d, export=%d, tooltip=%d WHERE field=%s', array($data['caption'], $param, $data['select_data_type'], $data['field'], $data['visible'], $data['required'], $data['filter'], $data['export'], $data['tooltip'], $field)); /* DB::Execute('UPDATE '.$this->tab.'_edit_history_data SET field=%s WHERE field=%s', array($new_id, $id)); DB::CompleteTrans();*/ DB::Execute('DELETE FROM '.$this->tab.'_callback WHERE freezed=1 AND field=%s', array($field)); if ($data['display_callback']) DB::Execute('INSERT INTO '.$this->tab.'_callback (callback,freezed,field) VALUES (%s,1,%s)', array($data['display_callback'], $data['field'])); DB::Execute('DELETE FROM '.$this->tab.'_callback WHERE freezed=0 AND field=%s', array($field)); if ($data['QFfield_callback']) DB::Execute('INSERT INTO '.$this->tab.'_callback (callback,freezed,field) VALUES (%s,0,%s)', array($data['QFfield_callback'], $data['field'])); $this->init(true, true); return false; } $form->display_as_column(); eval_js('RB_hide_form_fields();'); eval_js('RB_advanced_confirmation = "'.Epesi::escapeJS(__('Changing these settings may often cause system unstability. Are you sure you want to see advanced settings?')).'";'); eval_js('RB_advanced_settings();'); Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href()); Base_ActionBarCommon::add('back', __('Cancel'), $this->create_back_href()); return true; }
public function get_submit_form_js_by_name($form_name, $submited, $indicator, $queue = false) { if (!is_array($form_name)) { $form_name = array($form_name); } if (!isset($indicator)) { $indicator = __('Processing...'); } $fast = "+'&" . http_build_query(array('__action_module__' => $this->get_parent_path())) . "'"; $pre = ''; $chj = ''; $post = ''; foreach ($form_name as $f) { if ($submited) { $pre .= 'Epesi.confirmLeave.freeze(\'' . addslashes($f) . '\');'; $pre .= "\$('" . addslashes($f) . "').submited.value=1;"; } $pre .= "Event.fire(document,'e:submit_form','" . $f . "');"; $pre .= str_replace('this', "\$('" . addslashes($f) . "')", Libs_QuickFormCommon::get_on_submit_actions()); if ($chj) { $chj .= "+'&'+"; } $chj .= "\$('" . addslashes($f) . "').serialize()"; if ($submited) { $post .= "\$('" . addslashes($f) . "').submited.value=0;"; } } $s = $pre . "_chj(" . $chj . $fast . ",'" . Epesi::escapeJS($indicator) . "','" . ($queue ? 'queue' : '') . "');" . $post; return $s; }
<?php /** * @author Arkadiusz Bisaga <*****@*****.**> * @copyright Copyright © 2008, Telaxus LLC * @license MIT * @version 1.0 * @package epesi-utils * @subpackage recordbrowser */ if (!isset($_POST['id']) || !isset($_POST['state']) || !isset($_POST['element']) || !isset($_POST['tab']) || !isset($_POST['cid'])) { die('Invalid request: ' . print_r($_POST, true)); } define('JS_OUTPUT', 1); define('CID', $_POST['cid']); define('READ_ONLY_SESSION', true); require_once '../../../include.php'; ModuleManager::load_modules(); $id = json_decode($_POST['id']); $tab = json_decode($_POST['tab']); $state = json_decode($_POST['state']); $element = json_decode($_POST['element']); if (!Acl::is_user()) { die('alert("Unauthorized access");'); } Utils_RecordBrowserCommon::set_favs($tab, $id, $state); print '$("' . $element . '").innerHTML="' . Epesi::escapeJS(Utils_RecordBrowserCommon::get_fav_button_tags($tab, $id, $state)) . '";';
public function week() { $theme = $this->pack_module(Base_Theme::module_name()); Base_ThemeCommon::load_css('Utils_CalendarBusyReport', 'common'); $theme->assign('next7_href', $this->create_unique_href(array('date' => date('Y-m-d', $this->date + 604800)))); $theme->assign('next7_label', __('Next week')); $theme->assign('next_href', $this->create_unique_href(array('shift_week_day' => 1))); $theme->assign('next_label', __('Next day')); $theme->assign('today_href', $this->create_unique_href(array('date' => date('Y-m-d')))); $theme->assign('today_label', __('Today')); $theme->assign('prev_href', $this->create_unique_href(array('shift_week_day' => 0))); $theme->assign('prev_label', __('Previous day')); $theme->assign('prev7_href', $this->create_unique_href(array('date' => date('Y-m-d', $this->date - 604800)))); $theme->assign('prev7_label', __('Previous week')); $link_text = $this->create_unique_href_js(array('week_date' => '__YEAR__-__MONTH__-__DAY__')); $theme->assign('popup_calendar', Utils_PopupCalendarCommon::show('week_selector', $link_text, 'day', $this->settings['first_day_of_week'])); $week_shift = $this->get_module_variable('week_shift', 0); $first_day_of_displayed_week = date('w', $this->date) - $this->settings['first_day_of_week']; if ($first_day_of_displayed_week < 0) { $first_day_of_displayed_week += 7; } $diff = $week_shift - $first_day_of_displayed_week; $dis_week_from = strtotime(($diff < 0 ? $diff : '+' . $diff) . ' days', $this->date); //headers $day_headers = array(); $today = Base_RegionalSettingsCommon::time2reg(null, false, true, true, false); if (date('m', $dis_week_from) != date('m', $dis_week_from + 518400)) { $second_span_width = date('d', $dis_week_from + 518400); $header_month = array('first_span' => array('colspan' => 7 - $second_span_width, 'month' => __date('M', $dis_week_from), 'month_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from, 'tab' => 'Month')), 'year' => date('Y', $dis_week_from), 'year_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from, 'tab' => 'Year'))), 'second_span' => array('colspan' => $second_span_width, 'month' => __date('M', $dis_week_from + 518400), 'month_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from + 518400, 'tab' => 'Month')), 'year' => date('Y', $dis_week_from + 518400), 'year_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from + 518400, 'tab' => 'Year')))); } else { $header_month = array('first_span' => array('colspan' => 7, 'month' => __date('M', $dis_week_from), 'month_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from, 'tab' => 'Month')), 'year' => date('Y', $dis_week_from), 'year_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from, 'tab' => 'Year')))); } for ($i = 0; $i < 7; $i++) { $that_day = strtotime(date('Y-m-d', strtotime(date('Y-m-d 12:00:00', $dis_week_from)) + 3600 * 24 * $i) . ' ' . date('H:i:s', $dis_week_from)); $day_headers[] = array('date' => date('d', $that_day) . ' ' . __date('D', $that_day), 'style' => (date('Y-m-d', $that_day) == $today ? 'today' : 'other') . (date('N', $that_day) >= 6 ? '_weekend' : ''), 'link' => $this->create_unique_href(array('action' => 'switch', 'time' => $that_day, 'tab' => 'Day'))); } $theme->assign('header_month', $header_month); $theme->assign('day_headers', $day_headers); $theme->assign('head_col_width', $this->settings['head_col_width']); $report = array(); //timeline and ids $time_ids = array(); $timeline = array(); for ($i = 0; $i < 7; $i++) { $time_ids[$i] = array(); $today_t_timeless = strtotime(date('Y-m-d', strtotime(date('Y-m-d 12:00:00', $dis_week_from)) + 3600 * 24 * $i) . ' ' . date('H:i:s', $dis_week_from)); $today_t = Base_RegionalSettingsCommon::reg2time(date('Y-m-d', $today_t_timeless)); $today_date = date('Y-m-d', $today_t_timeless); $timeline[$today_date] = $this->get_timeline($today_date); $prev = null; foreach ($timeline[$today_date] as &$v) { if ($v['time'] === false) { $time_ids[$i][] = false; } elseif (is_string($v['time'])) { $ii = $today_t_timeless . '_' . $v['time']; $time_ids[$i][] = $ii; $report[$ii] = array(); // eval_js('$("UCcell_'.$ii.'").innerHTML="'.$ii.'";'); // *DEBUG* } else { $ii = $today_t + $v['time']; $time_ids[$i][] = $ii; $report[$ii] = array(); // eval_js('$("UCcell_'.$ii.'").innerHTML="'.Base_RegionalSettingsCommon::time2reg($ii).'";'); // *DEBUG* } $prev = $v; } } $navigation_bar_additions = ''; if (is_callable(array($this->event_module, 'get_navigation_bar_additions'))) { $event_module_instance = $this->init_module($this->event_module); $navigation_bar_additions = call_user_func(array($event_module_instance, 'get_navigation_bar_additions'), '', ''); } $theme->assign('navigation_bar_additions', $navigation_bar_additions); $theme->assign('time_ids', $time_ids); $theme->assign('timeline', reset($timeline)); $theme->assign('week_view_label', __('Week calendar')); //data //$dis_week_from = Base_RegionalSettingsCommon::reg2time($dis_week_from); //$dis_week_to = $dis_week_from+7*86400-1; $dis_week_to = date('Y-m-d', $dis_week_from + 7.5 * 86400); $dis_week_from = date('Y-m-d', $dis_week_from); $ret = $this->get_events($dis_week_from, $dis_week_to); $this->displayed_events = array('start' => $dis_week_from, 'end' => $dis_week_to, 'events' => $ret); $custom_keys = $this->settings['custom_rows']; $busy_labels = $this->settings['busy_labels']; foreach ($ret as $k => $ev) { if (!isset($ev['busy_label'])) { continue; } if (!is_array($ev['busy_label'])) { $ev['busy_label'] = array($ev['busy_label']); } ob_start(); Utils_CalendarBusyReportCommon::print_event($ev); $ev_print = ob_get_clean(); $day_start = explode(':', $this->settings['start_day']); $day_start = ($day_start[0] * 60 + $day_start[1]) * 60; if (!isset($ev['start'])) { $diff = 1; } else { $diff = ($day_start - ($ev['start'] - $today_t)) / 3600; } $dur = ceil($ev['duration'] / (strtotime($this->settings['interval']) - strtotime('0:00'))); if (isset($ev['timeless']) && $ev['timeless']) { if (!isset($ev['custom_row_key'])) { $ev['custom_row_key'] = 'timeless'; } $today_t_timeless = strtotime($ev['timeless']); if (isset($custom_keys[$ev['custom_row_key']])) { $dest_id = $today_t_timeless . '_' . $ev['custom_row_key']; if (isset($report[$dest_id])) { foreach ($ev['busy_label'] as $busy_label) { if (!isset($busy_labels[$busy_label])) { $busy_labels[$busy_label] = $busy_label; } if (!isset($report[$dest_id][$busy_label])) { $report[$dest_id][$busy_label] = ''; } $report[$dest_id][$busy_label] .= $ev_print; } } } else { // trigger_error('Invalid custom_row_key:'.$ev['custom_row_key'],E_USER_ERROR); continue; } } else { $today_t = Base_RegionalSettingsCommon::time2reg($ev['start'], true, true, true, false); $today_date = date('Y-m-d', strtotime($today_t)); $today_t = strtotime(date('Y-m-d H:i:s', Base_RegionalSettingsCommon::reg2time($today_date))); $ev_start = $ev['start'] - $today_t; if (!isset($timeline[$today_date])) { continue; } $ct = count($timeline[$today_date]); for ($i = 1, $j = 2; $j < $ct; $i++, $j++) { while ($timeline[$today_date][$i]['time'] === false) { $i++; } while (($timeline[$today_date][$j]['time'] === false || $i >= $j) && $j < $ct) { $j++; } if ($j == $ct) { break; } if ($timeline[$today_date][$i]['time'] <= $ev_start && $ev_start < $timeline[$today_date][$j]['time']) { break; } } for ($k = $i; $k < $i + $dur; $k++) { $dest_id = $today_t + $timeline[$today_date][$k]['time']; if (isset($report[$dest_id])) { foreach ($ev['busy_label'] as $busy_label) { if (!isset($busy_labels[$busy_label])) { $busy_labels[$busy_label] = $busy_label; } if (!isset($report[$dest_id][$busy_label])) { $report[$dest_id][$busy_label] = ''; } $report[$dest_id][$busy_label] .= $ev_print; } } } } } $theme->assign('report', $report); $theme->assign('busy_labels', $busy_labels); //ok, display $theme->display('week'); if ($this->custom_new_event_href_js !== null) { $jshref = call_user_func($this->custom_new_event_href_js, '__TIME__', '__TIMELESS__', '__OBJECT__'); } else { $jshref = $this->create_unique_href_js(array('action' => 'add', 'time' => '__TIME__', 'timeless' => '__TIMELESS__', 'object' => '__OBJECT__')); } eval_js('Utils_CalendarBusyReport.activate_dclick(\'' . Epesi::escapeJS($jshref, false) . '\')'); }
public static function get_file_leightbox($row, & $view_link = '') { static $th; if(!isset($th)) $th = Base_ThemeCommon::init_smarty(); if($row['original']==='') return ''; $links = array(); $lid = 'get_file_'.md5(serialize($row)); if(isset($_GET['save_google_docs']) && $_GET['save_google_docs']==$lid) { self::save_google_docs($row['id']); } if(isset($_GET['discard_google_docs']) && $_GET['discard_google_docs']==$lid) { self::discard_google_docs($row['id']); } $close_leightbox_js = 'leightbox_deactivate(\''.$lid.'\');'; if (Variable::get('utils_attachments_google_user',false) && preg_match('/\.(xlsx?|docx?|txt|odt|ods|csv)$/i',$row['original'])) { $label = __('Open with Google Docs'); $label = explode(' ', $label); $mid = floor(count($label) / 2); $label = implode(' ', array_slice($label, 0, $mid)).' '.implode(' ', array_slice($label, $mid)); $script = 'get_google_docs'; $onclick = '$(\'attachment_save_options_'.$row['id'].'\').style.display=\'\';$(\'attachment_download_options_'.$row['id'].'\').hide();'; $th->assign('save_options_id','attachment_save_options_'.$row['id']); $links['save'] = '<a href="javascript:void(0);" onclick="'.$close_leightbox_js.Module::create_href_js(array('save_google_docs'=>$lid)).'">'.__('Save Changes').'</a><br>'; $links['discard'] ='<a href="javascript:void(0);" onclick="'.$close_leightbox_js.Module::create_href_js(array('discard_google_docs'=>$lid)).'">'.__('Discard Changes').'</a><br>'; } else { $label = __('View'); $th->assign('save_options_id',''); $script = 'get'; $onclick = $close_leightbox_js; } $th->assign('download_options_id','attachment_download_options_'.$row['id']); $view_link = 'modules/Utils/Attachment/'.$script.'.php?'.http_build_query(array('id'=>$row['id'],'cid'=>CID,'view'=>1)); $links['view'] = '<a href="'.$view_link.'" target="_blank" onClick="'.$onclick.'">'.$label.'</a><br>'; $links['download'] = '<a href="modules/Utils/Attachment/get.php?'.http_build_query(array('id'=>$row['id'],'cid'=>CID)).'" onClick="leightbox_deactivate(\''.$lid.'\')">'.__('Download').'</a><br>'; load_js('modules/Utils/Attachment/remote.js'); if(!$row['crypted']) { $links['link'] = '<a href="javascript:void(0)" onClick="utils_attachment_get_link('.$row['id'].', '.CID.',\'get link\');leightbox_deactivate(\''.$lid.'\')">'.__('Get link').'</a><br>'; } $th->assign('filename',$row['original']); $f_filename = DATA_DIR.'/Utils_Attachment/'.$row['aid'].'/'.$row['id']; if(!file_exists($f_filename)) return 'missing file: '.$f_filename; $th->assign('file_size',__('File size: %s',array(filesize_hr($f_filename)))); $th->assign('labels',array( 'filename'=>__('Filename'), 'file_size'=>__('File size') )); foreach($links as $key=>&$l) { $th->assign($key,$l); $l = Base_ThemeCommon::parse_links($key, $l); } $th->assign('__link',$links); $custom_getters = array(); if(!$row['crypted']) { $getters = ModuleManager::call_common_methods('attachment_getters'); foreach($getters as $mod=>$arr) { if (is_array($arr)) foreach($arr as $caption=>$func) { $cus_id = md5($mod.$caption.serialize($func)); if(isset($_GET['utils_attachment_custom_getter']) && $_GET['utils_attachment_custom_getter']==$cus_id) call_user_func_array(array($mod.'Common',$func['func']),array($f_filename,$row['original'],$row['id'])); $custom_getters[] = array('open'=>'<a href="javascript:void(0)" onClick="'.Epesi::escapeJS(Module::create_href_js(array('utils_attachment_custom_getter'=>$cus_id)),true,false).';leightbox_deactivate(\''.$lid.'\')">','close'=>'</a>','text'=>$caption,'icon'=>$func['icon']); } } } $th->assign('custom_getters',$custom_getters); ob_start(); Base_ThemeCommon::display_smarty($th,'Utils_Attachment','download'); $c = ob_get_clean(); Libs_LeightboxCommon::display($lid,$c,__('Attachment')); return Libs_LeightboxCommon::get_open_href($lid); }
public static function get_file_leightbox($row, &$view_link = '') { static $th; if (!isset($th)) { $th = Base_ThemeCommon::init_smarty(); } if ($row['original'] === '') { return ''; } $links = array(); $lid = 'get_file_' . md5(serialize($row)); $close_leightbox_js = 'leightbox_deactivate(\'' . $lid . '\');'; $label = __('View'); $th->assign('save_options_id', ''); $script = 'get'; $onclick = $close_leightbox_js; $th->assign('download_options_id', 'attachment_download_options_' . $row['id']); $view_link = 'modules/Utils/Attachment/' . $script . '.php?' . http_build_query(array('id' => $row['id'], 'cid' => CID, 'view' => 1)); $links['view'] = '<a href="' . $view_link . '" target="_blank" onClick="' . $onclick . '">' . $label . '</a><br>'; $links['download'] = '<a href="modules/Utils/Attachment/get.php?' . http_build_query(array('id' => $row['id'], 'cid' => CID)) . '" onClick="leightbox_deactivate(\'' . $lid . '\')">' . __('Download') . '</a><br>'; load_js('modules/Utils/Attachment/remote.js'); if (!$row['crypted']) { $links['link'] = '<a href="javascript:void(0)" onClick="utils_attachment_get_link(' . $row['id'] . ', ' . CID . ',\'get link\');leightbox_deactivate(\'' . $lid . '\')">' . __('Get link') . '</a><br>'; } $th->assign('filename', $row['original']); $meta = Utils_FileStorageCommon::meta($row['filestorage_id']); $f_filename = $meta['file']; if (!file_exists($f_filename)) { return 'missing file: ' . $f_filename; } $th->assign('file_size', __('File size: %s', array(filesize_hr($f_filename)))); $th->assign('labels', array('filename' => __('Filename'), 'file_size' => __('File size'))); foreach ($links as $key => &$l) { $th->assign($key, $l); $l = Base_ThemeCommon::parse_links($key, $l); } $th->assign('__link', $links); $custom_getters = array(); if (!$row['crypted']) { $getters = ModuleManager::call_common_methods('attachment_getters'); foreach ($getters as $mod => $arr) { if (is_array($arr)) { foreach ($arr as $caption => $func) { $cus_id = md5($mod . $caption . serialize($func)); if (isset($_GET['utils_attachment_custom_getter']) && $_GET['utils_attachment_custom_getter'] == $cus_id) { call_user_func_array(array($mod . 'Common', $func['func']), array($f_filename, $row['original'], $row['id'])); } $custom_getters[] = array('open' => '<a href="javascript:void(0)" onClick="' . Epesi::escapeJS(Module::create_href_js(array('utils_attachment_custom_getter' => $cus_id)), true, false) . ';leightbox_deactivate(\'' . $lid . '\')">', 'close' => '</a>', 'text' => $caption, 'icon' => $func['icon']); } } } } $th->assign('custom_getters', $custom_getters); ob_start(); Base_ThemeCommon::display_smarty($th, 'Utils_Attachment', 'download'); $c = ob_get_clean(); Libs_LeightboxCommon::display($lid, $c, __('Attachment')); return Libs_LeightboxCommon::get_open_href($lid); }
/** * For internal use only. */ public function browse($name = '', $root = true) { if ($this->is_back()) { return false; } if (isset($_REQUEST['node_position'])) { list($node_id, $position) = $_REQUEST['node_position']; Utils_CommonDataCommon::change_node_position($node_id, $position); } $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'browse' . md5($name)); $gb->set_table_columns(array(array('name' => __('Position'), 'width' => 5, 'order' => 'position'), array('name' => __('Key'), 'width' => 20, 'order' => 'akey', 'search' => 1, 'quickjump' => 'akey'), array('name' => __('Value'), 'width' => 20, 'order' => 'value', 'search' => 1))); print '<h2>' . $name . '</h2><br>'; $ret = Utils_CommonDataCommon::get_translated_array($name, true, true); foreach ($ret as $k => $v) { $gb_row = $gb->get_new_row(); $gb_row->add_data($v['position'], $k, $v['value']); // ****** CommonData value translation $gb_row->add_action($this->create_callback_href(array($this, 'browse'), array($name . '/' . $k, false)), 'View'); if (!$v['readonly']) { $gb_row->add_action($this->create_callback_href(array($this, 'edit'), array($name, $k)), 'Edit'); $gb_row->add_action($this->create_confirm_callback_href(__('Delete array') . ' \'' . Epesi::escapeJS($name . '/' . $k, false) . '\'?', array('Utils_CommonData', 'remove_array'), array($name . '/' . $k)), 'Delete'); } $node_id = $v['id']; $gb_row->add_action('class="move-handle"', 'Move', __('Drag to change node order'), 'move-up-down'); $gb_row->set_attrs("node=\"{$node_id}\" class=\"sortable\""); } $gb->set_default_order(array(__('Position') => 'ASC')); //$this->display_module($gb); $this->display_module($gb, array(true), 'automatic_display'); // sorting load_js($this->get_module_dir() . 'sort_nodes.js'); $table_md5 = md5($gb->get_path()); eval_js("utils_commondata_sort_nodes_init(\"{$table_md5}\")"); Base_ActionBarCommon::add('settings', __('Reset Order By Key'), $this->create_callback_href(array('Utils_CommonDataCommon', 'reset_array_positions'), $name)); Base_ActionBarCommon::add('add', __('Add array'), $this->create_callback_href(array($this, 'edit'), $name)); if (!$root) { Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href()); } return true; }
} } } $js .= '$("grid_selected_frames").value="' . implode(';', $selected_frames) . '";'; $timeframe_string = '<table class="time_frames">'; if (isset($_SESSION['client']['utils_planner']['date'])) { $day = $_SESSION['client']['utils_planner']['date']; } else { $day = Utils_PopupCalendarCommon::get_first_day_of_week(); } $count = 0; do { if (isset($timeframe[$day])) { foreach ($timeframe[$day] as $v) { $timeframe_string .= $v; } } if (isset($_SESSION['client']['utils_planner']['date'])) { $day = strtotime('+1 day', $day); } else { $day++; if ($day == 7) { $day = 0; } } $count++; } while ($count < 7); $timeframe_string .= '</table>'; $js .= '$("Utils_Planner__time_frames").innerHTML="' . Epesi::escapeJS($timeframe_string) . '";'; $js .= Utils_PlannerCommon::timeframe_changed($selected_frames); print $js;