예제 #1
0
 public static function get($id, $content, $header = '', $big = 0)
 {
     if (MOBILE_DEVICE) {
         return '';
     }
     static $init = true;
     if ($init) {
         Base_ThemeCommon::load_css('Libs/Leightbox', 'default', false);
         load_js('modules/Libs/Leightbox/leightbox.js');
         $init = false;
     }
     ob_start();
     print '<div id="' . $id . '" big="1" class="leightbox">';
     print '<input type="hidden" id="' . $id . '_bigsize" value="' . ($big ? 1 : 0) . '" />';
     if ($big) {
         eval_js('s = $(\'' . $id . '\').style;' . 's.top = \'5%\';' . 's.left = \'5%\';' . 's.width = \'90%\';' . 's.height = \'90%\';' . 's.padding = \'0px\';');
     }
     $smarty = Base_ThemeCommon::init_smarty();
     $smarty->assign('close_href', 'href="javascript:leightbox_deactivate(\'' . $id . '\')"');
     $smarty->assign('content', $content);
     $smarty->assign('header', $header);
     $smarty->assign('close_label', __('Close'));
     $smarty->assign('resize_label', __('Resize'));
     $smarty->assign('close_href', 'href="javascript:leightbox_deactivate(\'' . $id . '\')"');
     Base_ThemeCommon::display_smarty($smarty, 'Libs_Leightbox');
     print '</div>';
     return ob_get_clean();
 }
예제 #2
0
 public static function get_installed_applets_html()
 {
     $colors = Base_DashboardCommon::get_available_colors();
     $app_cap = ModuleManager::call_common_methods('applet_caption');
     asort($app_cap);
     $app_info = ModuleManager::call_common_methods('applet_info');
     $html = '';
     foreach ($app_cap as $name => $cap) {
         if (!$cap) {
             continue;
         }
         $th = Base_ThemeCommon::init_smarty();
         $id = str_replace('_', '-', $name);
         if (!isset($app_info[$name])) {
             $app_info[$name] = '';
         }
         $th->assign('content', '<div class="content" style="padding:4px;" id="dashboard_applet_content_' . $id . '">' . $app_info[$name] . '</div>');
         $th->assign('handle_class', 'handle');
         $th->assign('caption', $cap);
         $th->assign('color', $colors[0]['class']);
         $remove_button = Base_DashboardCommon::get_remove_applet_button($id, false);
         $th->assign('remove', $remove_button);
         $th->assign('__link', array('remove' => Base_ThemeCommon::parse_links('remove', $remove_button)));
         //print('<xmp>'.self::get_remove_applet_button(null, false).'</xmp><br>');
         $th->assign('actions', array());
         $th->assign('config_mode', true);
         $html .= '<div class="applet" searchkey="' . strtolower($cap ? $cap : $name) . ';' . strtolower($app_info[$name]) . '" id="ab_item_' . 'new_' . $id . '">';
         ob_start();
         Base_ThemeCommon::display_smarty($th, 'Base_Dashboard', 'default');
         $html .= ob_get_clean();
         $html .= '</div>';
     }
     return $html;
 }
예제 #3
0
파일: Theme_0.php 프로젝트: cretzu89/EPESI
 /**
  * For internal use only.
  */
 public function construct()
 {
     $this->set_inline_display();
     if (!isset(self::$theme)) {
         self::$theme = Base_ThemeCommon::get_default_template();
     }
     $this->smarty = Base_ThemeCommon::init_smarty();
 }
예제 #4
0
 public static function print_event($ev, $mode = '', $with_div = true)
 {
     $th = Base_ThemeCommon::init_smarty();
     $ex = self::process_event($ev);
     $th->assign('event_id', $ev['id']);
     $th->assign('draggable', !isset($ev['draggable']) || $ev['draggable'] === true);
     $title = $ev['title'];
     $title_st = strip_tags($ev['title']);
     $title_s = $title;
     $th->assign('with_div', $with_div);
     $th->assign('title', $title);
     $th->assign('title_s', $title_s);
     $th->assign('description', $ev['description']);
     $th->assign('color', $ev['color']);
     $th->assign('start', $ex['start']);
     $th->assign('start_time', $ex['start_time']);
     $th->assign('end_time', $ex['end_time']);
     $th->assign('start_date', $ex['start_date']);
     $th->assign('end_date', $ex['end_date']);
     $th->assign('start_day', $ex['start_day']);
     $th->assign('end_day', $ex['end_day']);
     $th->assign('end', $ex['end']);
     $th->assign('duration', $ex['duration']);
     $th->assign('show_hide_info', __('Click to show / hide menu'));
     $th->assign('additional_info', $ev['additional_info']);
     $th->assign('additional_info2', $ev['additional_info2']);
     if (isset($ev['custom_tooltip'])) {
         $th->assign('custom_tooltip', $ev['custom_tooltip']);
     }
     ob_start();
     Base_ThemeCommon::display_smarty($th, 'Utils_Calendar', 'event_tip');
     $tip = ob_get_clean();
     $th->assign('tip_tag_attrs', Utils_TooltipCommon::open_tag_attrs($tip, false));
     if (!isset($ev['view_action']) || $ev['view_action'] === true) {
         $th->assign('view_href', Module::create_href(array('UCev_id' => $ev['id'], 'UCaction' => 'view')));
     } elseif ($ev['view_action'] !== false) {
         $th->assign('view_href', $ev['view_action']);
     }
     if (!isset($ev['edit_action']) || $ev['edit_action'] === true) {
         $th->assign('edit_href', Module::create_href(array('UCev_id' => $ev['id'], 'UCaction' => 'edit')));
     } elseif ($ev['edit_action'] !== false) {
         $th->assign('edit_href', $ev['edit_action']);
     }
     $link_text = Module::create_href_js(array('UCev_id' => $ev['id'], 'UCaction' => 'move', 'UCdate' => '__YEAR__-__MONTH__-__DAY__'));
     if (!isset($ev['move_action']) || $ev['move_action'] === true) {
         $th->assign('move_href', Utils_PopupCalendarCommon::create_href('move_event' . str_replace(array('#', '-'), '_', $ev['id']), $link_text, null, null, 'popup.clonePosition(\'utils_calendar_event:' . $ev['id'] . '\',{setWidth:false,setHeight:false,offsetTop:$(\'utils_calendar_event:' . $ev['id'] . '\').getHeight()})'));
     }
     if (!isset($ev['delete_action']) || $ev['delete_action'] === true) {
         $th->assign('delete_href', Module::create_confirm_href(__('Delete this event?'), array('UCev_id' => $ev['id'], 'UCaction' => 'delete')));
     } elseif ($ev['delete_action'] !== false) {
         $th->assign('delete_href', $ev['delete_action']);
     }
     $th->assign('handle_class', 'handle');
     $th->assign('custom_actions', $ev['actions']);
     Base_ThemeCommon::display_smarty($th, 'Utils_Calendar', 'event' . ($mode ? '_' . $mode : ''));
 }
예제 #5
0
	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);
	}
예제 #6
0
 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;
 }
예제 #7
0
 public static function display($header, $content, $info = false)
 {
     $l = Variable::get('logo_file', false);
     if (!$l) {
         $l = Base_ThemeCommon::get_template_file('images/logo-small.png');
     }
     $smarty = Base_ThemeCommon::init_smarty();
     $smarty->assign('header', $header);
     $smarty->assign('contents', $content);
     $smarty->assign('info', $info);
     $smarty->assign('footer', '');
     $smarty->assign('logo', $l);
     $smarty->assign('url', get_epesi_url());
     Base_ThemeCommon::display_smarty($smarty, 'Utils_FrontPage', 'default');
 }
예제 #8
0
 public static function drawLeightbox($prefix)
 {
     if (MOBILE_DEVICE) {
         return;
     }
     $meetings = CRM_MeetingInstall::is_installed();
     $tasks = CRM_TasksInstall::is_installed();
     $phonecall = CRM_PhoneCallInstall::is_installed();
     self::check_location();
     if (!isset(self::$leightbox_ready[$prefix])) {
         self::$leightbox_ready[$prefix] = true;
         $theme = Base_ThemeCommon::init_smarty();
         eval_js_once($prefix . '_followups_deactivate = function(){leightbox_deactivate(\'' . $prefix . '_followups_leightbox\');}');
         if ($meetings) {
             $theme->assign('new_meeting', array('open' => '<a id="' . $prefix . '_new_meeting_button" onclick="' . $prefix . '_set_action(\'new_meeting\');' . $prefix . '_submit_form();">', 'text' => __('New Meeting'), 'close' => '</a>'));
             eval_js('Event.observe(\'' . $prefix . '_new_meeting_button\',\'click\', ' . $prefix . '_followups_deactivate)');
         }
         if ($tasks) {
             $theme->assign('new_task', array('open' => '<a id="' . $prefix . '_new_task_button" onclick="' . $prefix . '_set_action(\'new_task\');' . $prefix . '_submit_form();">', 'text' => __('New Task'), 'close' => '</a>'));
             eval_js('Event.observe(\'' . $prefix . '_new_task_button\',\'click\', ' . $prefix . '_followups_deactivate)');
         }
         if ($phonecall) {
             $theme->assign('new_phonecall', array('open' => '<a id="' . $prefix . '_new_phonecall_button" onclick="' . $prefix . '_set_action(\'new_phonecall\');' . $prefix . '_submit_form();">', 'text' => __('New Phonecall'), 'close' => '</a>'));
             eval_js('Event.observe(\'' . $prefix . '_new_phonecall_button\',\'click\', ' . $prefix . '_followups_deactivate)');
         }
         $theme->assign('just_close', array('open' => '<a id="' . $prefix . '_just_close_button" onclick="' . $prefix . '_set_action(\'none\');' . $prefix . '_submit_form();">', 'text' => __('Save'), 'close' => '</a>'));
         eval_js('Event.observe(\'' . $prefix . '_just_close_button\',\'click\', ' . $prefix . '_followups_deactivate)');
         eval_js($prefix . '_submit_form = function () {' . '$(\'' . $prefix . '_follow_up_form\').submited.value=1;Epesi.href($(\'' . $prefix . '_follow_up_form\').serialize(), \'processing...\');$(\'' . $prefix . '_follow_up_form\').submited.value=0;' . '}');
         eval_js($prefix . '_set_action = function (arg) {' . 'document.forms["' . $prefix . '_follow_up_form"].action.value = arg;' . '}');
         eval_js($prefix . '_set_id = function (id) {' . 'document.forms["' . $prefix . '_follow_up_form"].id.value = id;' . '$("' . $prefix . '_closecancel").value=3;' . '$("' . $prefix . '_note").value="";' . '}');
         $theme->assign('form_open', '<form id="' . $prefix . '_follow_up_form" name="' . $prefix . '_follow_up_form" method="POST">' . '<input type="hidden" name="submited" value="0" />' . '<input type="hidden" name="form_name" value="' . $prefix . '_follow_up_form" />' . '<input type="hidden" name="id" value="" />' . '<input type="hidden" name="action" value="" />');
         $status_select_options = '';
         $statuses = Utils_CommonDataCommon::get_translated_array('CRM/Status');
         foreach ($statuses as $key => $value) {
             $status_select_options .= '<option value="' . htmlspecialchars($key) . '"' . ($key == 3 ? ' selected="1"' : '') . '>' . htmlspecialchars($value) . '</option>';
         }
         $theme->assign('form_closecancel', array('label' => __('Status'), 'html' => '<select name="closecancel" id="' . $prefix . '_closecancel" value="0">' . $status_select_options . '</select>'));
         $theme->assign('form_note', array('label' => __('Note'), 'html' => '<textarea name="note" id="' . $prefix . '_note"></textarea>'));
         $theme->assign('form_close', '</form>');
         ob_start();
         Base_ThemeCommon::display_smarty($theme, 'CRM_Followup', 'leightbox');
         $profiles_out = ob_get_clean();
         Libs_LeightboxCommon::display($prefix . '_followups_leightbox', $profiles_out, __('Follow-up'));
     }
 }
예제 #9
0
 public static function watchdog_label($tab, $cat, $rid, $events = array(), $label = null, $details = true)
 {
     $ret = array('category' => $cat);
     if ($rid !== null) {
         $r = self::get_record($tab, $rid);
         if ($r === null) {
             return null;
         }
         if (!self::get_access($tab, 'view', $r)) {
             return null;
         }
         if (is_array($label)) {
             $label = Utils_RecordBrowserCommon::record_link_open_tag_r($tab, $r) . call_user_func($label, $r, true) . Utils_RecordBrowserCommon::record_link_close_tag();
             $label = self::create_default_record_tooltip_ajax($label, $tab, $rid);
         } elseif ($label) {
             $label = Utils_RecordBrowserCommon::create_linked_label_r($tab, $label, $r);
             $label = self::create_default_record_tooltip_ajax($label, $tab, $rid);
         } else {
             $label = Utils_RecordBrowserCommon::create_default_linked_label($tab, $rid, false, false);
         }
         $ret['title'] = $label;
         $ret['view_href'] = Utils_RecordBrowserCommon::create_record_href($tab, $rid);
         $events_display = array();
         $events = array_reverse($events);
         $other_events = array();
         $header = false;
         foreach ($events as $v) {
             if (count($events_display) > 20) {
                 $other_events[__('And more...')] = 1;
                 break;
             }
             $param = explode('_', $v);
             switch ($param[0]) {
                 case 'C':
                     $what = 'Created';
                     $event_display = array('who' => Base_UserCommon::get_user_label($r['created_by'], true), 'when' => Base_RegionalSettingsCommon::time2reg($r['created_on']), 'what' => _V($what));
                     break;
                 case 'D':
                     if (!isset($what)) {
                         $what = 'Deleted';
                     }
                 case 'R':
                     if (!isset($what)) {
                         $what = 'Restored';
                     }
                     if (!isset($param[1])) {
                         $event_display = array('who' => '', 'when' => '', 'what' => _V($what));
                         break;
                     }
                 case 'E':
                     $event_display = self::get_edit_details_modify_record($tab, $r['id'], $param[1], $details);
                     if (isset($event_display['what']) && !empty($event_display['what'])) {
                         $header = true;
                     }
                     break;
                 case 'N':
                     $event_display = false;
                     switch ($param[1]) {
                         case '+':
                             $action = __('Note linked');
                             break;
                         case '-':
                             $action = __('Note unlinked');
                             break;
                         default:
                             if (!isset($other_events[$param[1]])) {
                                 $other_events[$param[1]] = 0;
                             }
                             $other_events[$param[1]]++;
                             $event_display = null;
                             break;
                     }
                     if ($event_display === false) {
                         $date = isset($param[3]) ? Base_RegionalSettingsCommon::time2reg($param[3]) : '';
                         $who = isset($param[4]) ? Base_UserCommon::get_user_label($param[4], true) : '';
                         $action .= ' - ' . self::create_default_linked_label('utils_attachment', $param[2]);
                         $event_display = array('what' => $action, 'who' => $who, 'when' => $date);
                     }
                     break;
                 default:
                     $event_display = array('what' => _V($v));
             }
             if ($event_display) {
                 $events_display[] = $event_display;
             }
         }
         foreach ($other_events as $k => $v) {
             $events_display[] = array('what' => _V($k) . ($v > 1 ? ' [' . $v . ']' : ''));
         }
         if ($events_display) {
             $theme = Base_ThemeCommon::init_smarty();
             if ($header) {
                 $theme->assign('header', array(__('Field'), __('Old value'), __('New value')));
             }
             $theme->assign('events', $events_display);
             $tpl = 'changes_list';
             if (Utils_WatchdogCommon::email_mode()) {
                 $record_data = self::get_record_tooltip_data($tab, $rid);
                 $theme->assign('record', $record_data);
                 $tpl = 'changes_list_email';
             }
             ob_start();
             Base_ThemeCommon::display_smarty($theme, 'Utils_RecordBrowser', $tpl);
             $output = ob_get_clean();
             $ret['events'] = $output;
         } else {
             // if we've generated empty events for certain record, then
             // it's possible that some of the fields, that have changed,
             // are hidden so we have to check if there are any other events
             // If all events are the same and output is empty we can safely
             // mark all as notified.
             $all_events = Utils_WatchdogCommon::check_if_notified($tab, $rid);
             if (count($all_events) == count($events)) {
                 Utils_WatchdogCommon::notified($tab, $rid);
             }
             $ret = null;
         }
     }
     return $ret;
 }
예제 #10
0
 public static function mobile_table($cols, $data, $enable_sort = true)
 {
     if ($enable_sort && is_string($enable_sort) && !isset($_GET['order'])) {
         $x = explode(' ', $enable_sort);
         foreach ($cols as $i => $v) {
             if ($x[0] == $v['order']) {
                 $_GET['order'] = $i;
             }
         }
         if (isset($_GET['order'])) {
             if (count($x) < 2) {
                 $_GET['order_dir'] = 'asc';
             } else {
                 $_GET['order_dir'] = $x[1];
             }
         }
     }
     $th = Base_ThemeCommon::init_smarty();
     $all_width = 0;
     foreach ($cols as $v) {
         if (array_key_exists('display', $v) && $v['display'] == false) {
             continue;
         }
         if (isset($v['width'])) {
             $all_width += $v['width'];
         }
     }
     $headers = array();
     foreach ($cols as $i => $v) {
         if (array_key_exists('display', $v) && $v['display'] == false) {
             continue;
         }
         if (isset($v['order'])) {
             $is_order = true;
         }
         $headers[$i] = array();
         if (isset($_GET['order']) && isset($_GET['order_dir']) && $i == $_GET['order']) {
             $sort_direction = $_GET['order_dir'] == 'desc' ? 'asc' : 'desc';
             $sort = 'style="padding-right: 12px; background-image: url(' . Base_ThemeCommon::get_template_file('Utils_GenericBrowser', 'sort-' . $sort_direction . 'ending.png') . '); background-repeat: no-repeat; background-position: right;"';
         } else {
             $sort = '';
             $sort_direction = 'asc';
         }
         $headers[$i]['label'] = (isset($v['preppend']) ? $v['preppend'] : '') . (isset($v['order']) ? '<a href="mobile.php?' . http_build_query(array_merge($_GET, array('order' => $i, 'order_dir' => $sort_direction))) . '">' . '<span ' . $sort . '>' . $v['name'] . '</span></a>' : '<span>' . $v['name'] . '</span>') . (isset($v['append']) ? $v['append'] : '');
         $headers[$i]['attrs'] = '';
         if ($all_width && isset($v['width'])) {
             $headers[$i]['attrs'] .= 'style="width: ' . intval(100 * $v['width'] / $all_width) . '%" ';
         }
         $headers[$i]['attrs'] .= 'nowrap="1" ';
     }
     $th->assign('cols', array_values($headers));
     //sort data
     if ($enable_sort && isset($_GET['order']) && isset($_GET['order_dir'])) {
         $col = array();
         foreach ($data as $j => $d) {
             foreach ($d as $i => $c) {
                 if (isset($cols[$i]['order']) && $i == $_GET['order']) {
                     if (is_array($c)) {
                         if (isset($c['order_value'])) {
                             $xxx = $c['order_value'];
                         } else {
                             $xxx = $c['value'];
                         }
                     } else {
                         $xxx = $c;
                     }
                     if (isset($cols[$i]['order_preg'])) {
                         $ret = array();
                         preg_match($cols[$i]['order_preg'], $xxx, $ret);
                         $xxx = isset($ret[1]) ? $ret[1] : '';
                     }
                     $xxx = strip_tags(strtolower($xxx));
                     $col[$j] = $xxx;
                 }
             }
         }
         asort($col);
         $data2 = array();
         foreach ($col as $j => $v) {
             $data2[] = $data[$j];
         }
         if ($_GET['order_dir'] != 'asc') {
             $data2 = array_reverse($data2);
         }
         $data = $data2;
     }
     $out_data = array();
     foreach ($data as $row) {
         foreach ($row as $k => $cell) {
             if (!isset($cols[$k]) || array_key_exists('display', $cols[$k]) && $cols[$k]['display'] == false) {
                 continue;
             }
             if (!is_array($cell)) {
                 $cell .= '&nbsp;';
                 $out_data[] = array('label' => $cell, 'attrs' => '');
             } else {
                 if (!isset($cell['attrs'])) {
                     $cell['attrs'] = '';
                 }
                 if (!isset($cell['label'])) {
                     $cell['label'] = '';
                 }
                 $cell['label'] .= '&nbsp;';
                 $out_data[] = $cell;
             }
         }
     }
     unset($data);
     $th->assign('data', $out_data);
     Base_ThemeCommon::display_smarty($th, Utils_GenericBrowser::module_name(), 'mobile');
 }
예제 #11
0
    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('&nbsp;', array_slice($label, 0, $mid)).' '.implode('&nbsp;', 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);
    }
예제 #12
0
 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);
 }
예제 #13
0
 /**
  * Create a leightbox with buttons
  *
  * @param array $links array of array('href' => .. , 'label' => ..)
  *
  * @return string href to open leightbox
  */
 protected static function choose_box_href(array $links)
 {
     $unique_id = md5(serialize($links));
     $popup_id = 'print_choice_popup_' . $unique_id;
     $header = __('Select document template to print');
     $launchpad = array();
     $deactivate = " onclick=\"leightbox_deactivate('{$popup_id}')\"";
     foreach ($links as $template) {
         $launchpad[] = array('href' => $template['href'] . $deactivate, 'label' => $template['label']);
     }
     $th = Base_ThemeCommon::init_smarty();
     $th->assign('icons', $launchpad);
     ob_start();
     Base_ThemeCommon::display_smarty($th, self::Instance()->get_type(), 'launchpad');
     $content = ob_get_clean();
     Libs_LeightboxCommon::display($popup_id, $content, $header);
     return Libs_LeightboxCommon::get_open_href($popup_id);
 }
예제 #14
0
파일: Printer.php 프로젝트: cretzu89/EPESI
 /**
  * Create a new section of document.
  *
  * @see print_document
  *
  * @return Smarty
  */
 protected function new_section()
 {
     $smarty = Base_ThemeCommon::init_smarty();
     return $smarty;
 }