public function setCode() { $wo[] = 'stickyHeaders : \'ts-stickyHeader\''; $wo[] = 'resizable : true'; //sort if (parent::$sorts) { //row grouping if (parent::$group) { $gc = ['$(table).find(\'.group-header\').addClass(\'info\');']; $wo[] = $this->iterate($gc, 'group_callback : function($cell, $rows, column, table){', $this->nt3 . '}', $this->nt4, ''); $wo[] = 'group_collapsible : true'; if (parent::$ajax) { $wo[] = 'group_count : false'; } else { $wo[] = 'group_count : \' ({num})\''; } } //saveSort if (isset(parent::$s['sorts']['type']) && strpos(parent::$s['sorts']['type'], 'save') !== false) { $wo[] = 'saveSort : true'; } } //now incorporate options which are handled in child classes $classes = ['Filter', 'Pager', 'Math']; foreach ($classes as $option) { $optarray = Table_Factory::build('WidgetOptions' . $option, parent::$s, 'code')->getOptionArray(); $wo = $optarray === false ? $wo : array_merge($wo, $optarray); } if (count($wo) > 0) { $code = $this->iterate($wo, $this->nt2 . 'widgetOptions : {', $this->nt2 . '}', $this->nt3, ''); parent::$code[self::$level1][self::$level2] = $code; } }
/** * This is the public function called to apply jQuery Tablesorter to a table. * This function will then call itself to call the appropriate Table_Settings class to build the settings * Then this function calls the Table_Manager class, passing the table and user settings * The Table_Manager class calls the Table_Code_Manager class to generate the jQuery code based on the table settings * The Table_Code_Manager class will call this function to call various other the Table_Code classes to create * the various sections of jQuery code and then put the sections together to create the final complete code * The Table_Manager class then loads the complete jQuery code into the header * * @param $name must correspond to a file in Table/Settings * @param null $settings optional user-defined settings array which will override defaults * - can be partial, ie only part of the array defined * @param string $type used along with $name to tell this function which class to call * * @return bool|Table_Manager */ public static function build($name, $settings = null, $type = 'manager') { if (Table_Check::isEnabled()) { switch ($type) { case 'manager': return new Table_Manager(Table_Factory::build($name, $settings, 'table')->s); break; case 'table': $class = 'Table_Settings_' . ucfirst($name); return new $class($settings); break; case 'code': $class = 'Table_Code_' . ucfirst($name); if (is_array($settings)) { return new $class($settings); } else { return false; } break; case 'plugin': return new Table_Plugin(); } } else { return false; } }
/** * Call the classes for each section in the order determined by the $subclasses property * and put sections together into final overall jQuery code */ public function setCode() { foreach ($this->subclasses as $key => $val) { if (empty($val)) { $instance = Table_Factory::build($key, parent::$s, 'code'); $instance::$level1 = $key; $instance::$level2 = null; $instance->setCode(); } elseif (is_array($val)) { foreach ($val as $key2 => $val2) { if (empty($val2)) { $instance = Table_Factory::build($key2, parent::$s, 'code'); $instance::$level1 = $key; $instance::$level2 = $key2; $instance->setCode(); } } } } //put sections together into final overall code self::$code['main'] = $this->iterate(self::$code['main'], $this->nt . '$(\'' . self::$tid . '\').tablesorter({', $this->nt . '})', '', ''); if (empty(self::$code['pager'])) { self::$code['main'] .= ';'; } $parts = ''; foreach (self::$code as $section) { $parts .= $section; } //unhide div holding the table $parts .= $this->nt . '$(\'div#' . self::$id . '\').css(\'visibility\', \'visible\');'; self::$code = $parts; }
/** * This is the public function called to apply jQuery Tablesorter to a table. * * @param $name must correspond to a file in Table/Settings * @param null $settings optional user-defined settings array which will override defaults * - can be partial, ie only part of the array defined * @param string $type used along with $name to tell this function which class to call * * @return bool|Table_Manager */ public static function build($name, $settings = null, $type = 'manager') { global $prefs; if ($prefs['disableJavascript'] == 'n' && $prefs['feature_jquery_tablesorter'] == 'y') { switch ($type) { case 'manager': return new Table_Manager(Table_Factory::build($name, $settings, 'table')->s); break; case 'table': $class = 'Table_Settings_' . ucfirst($name); return new $class($settings); break; case 'code': $class = 'Table_Code_' . ucfirst($name); if (is_array($settings)) { return new $class($settings); } else { return false; } break; case 'plugin': return new Table_Plugin(); } } else { return false; } }
function wikiplugin_trackerlist($data, $params) { global $tiki_p_admin_trackers, $prefs, $tiki_p_view_trackers, $user, $page, $tiki_p_tracker_vote_ratings, $tiki_p_tracker_view_ratings, $tiki_p_export_tracker, $tiki_p_watch_trackers, $tiki_p_edit; $userlib = TikiLib::lib('user'); $tikilib = TikiLib::lib('tiki'); $trklib = TikiLib::lib('trk'); $smarty = TikiLib::lib('smarty'); $notificationlib = TikiLib::lib('notification'); static $iTRACKERLIST = 0; ++$iTRACKERLIST; $smarty->assign('iTRACKERLIST', $iTRACKERLIST); $default = array('calendarfielddate' => '', 'wiki' => '', 'calendarviewmode' => 'month', 'calendarstickypopup' => 'n', 'calendarbeginmonth' => 'y', 'calendarviewnavbar' => 'y', 'calendartitle' => '', 'calendardelta' => '', 'force_compile' => 'n', 'editable' => array(), 'editableall' => 'n'); $params = array_merge($default, $params); extract($params, EXTR_SKIP); $skip_status_perm_check = false; if (isset($force_separate_compile) && $force_separate_compile == 'y') { $smarty->assign('force_separate_compile', 'y'); } if ($prefs['feature_trackers'] != 'y' || !isset($trackerId) || !($tracker_info = $trklib->get_tracker($trackerId))) { return $smarty->fetch("wiki-plugins/error_tracker.tpl"); } else { global $auto_query_args; $auto_query_args_local = array('trackerId', 'tr_initial', "tr_sort_mode{$iTRACKERLIST}", 'tr_user', 'filterfield', 'filtervalue', 'exactvalue', 'itemId', "tr_offset{$iTRACKERLIST}"); $auto_query_args = empty($auto_query_args) ? $auto_query_args_local : array_merge($auto_query_args, $auto_query_args_local); $smarty->assign('listTrackerId', $trackerId); $definition = Tracker_Definition::get($trackerId); $tracker_info = $definition->getInformation(); if (!isset($sort)) { $sort = 'n'; } $perms = $tikilib->get_perm_object($trackerId, 'tracker', $tracker_info, false); if ($perms['tiki_p_view_trackers'] != 'y' && !$user) { return; } $userCreatorFieldId = $definition->getAuthorField(); $groupCreatorFieldId = $definition->getWriterGroupField(); if ($perms['tiki_p_view_trackers'] != 'y' && !$definition->isEnabled('writerCanModify') && !$definition->isEnabled('userCanSeeOwn') && empty($userCreatorFieldId) && empty($groupCreatorFieldId)) { return; } $smarty->assign_by_ref('perms', $perms); if (!empty($fields)) { $limit = $fields; } else { $limit = ''; } // Make sure limit is an array if (!is_array($limit) && !empty($limit)) { $limit = explode(':', $limit); } if (!empty($filterfield) && !empty($limit)) { $limit = array_unique(array_merge($limit, $filterfield)); } // for some reason if param popup is set but empty, the array contains 2 empty elements. We filter them out. if (isset($popup)) { $popup = array_filter($popup); if (!empty($popup)) { $limit = array_unique(array_merge($limit, $popup)); } } if (!empty($calendarfielddate)) { $limit = array_unique(array_merge($limit, $calendarfielddate)); } if (!empty($limit) && $trklib->test_field_type($limit, array('C'))) { $limit = array(); } $allfields = $trklib->list_tracker_fields($trackerId, 0, -1, 'position_asc', '', true, '', $trklib->flaten($limit)); if (!empty($fields)) { $listfields = $fields; //We must include the $calendarfielddate, even if they are not in the listfields if (!empty($calendarfielddate)) { foreach ($calendarfielddate as $f) { if (!in_array($f, $listfields)) { $listfields[] = $f; } } } if ($sort == 'y') { $allfields = $trklib->sort_fields($allfields, $listfields); } } elseif (!empty($wiki) || !empty($tpl) || !empty($tplwiki)) { if (!empty($wiki)) { $listfields = $trklib->get_pretty_fieldIds($wiki, 'wiki', $prettyModifier, $trackerId); } elseif (!empty($tplwiki)) { $listfields = $trklib->get_pretty_fieldIds($tplwiki, 'wiki', $prettyModifier, $trackerId); } else { $listfields = $trklib->get_pretty_fieldIds($tpl, 'tpl', $prettyModifier, $trackerId); } } else { $listfields = ''; } if (!empty($compute) && !empty($listfields)) { if (preg_match_all('/[0-9.]+/', $compute, $matches)) { foreach ($matches[0] as $f) { if (!in_array($f, $listfields)) { $listfields[] = $f; } } } } /*** tablesorter ***/ //note whether ajax is needed $tsServer = isset($params['server']) && $params['server'] === 'y' ? true : false; $tsOn = isset($sortable) && $sortable !== 'n' && Table_Check::isEnabled($tsServer); $smarty->assign('tsOn', $tsOn); //note whether this is the initial tablesorter ajax call or a subsequent ajax call $tsAjax = Table_Check::isAjaxCall(); $smarty->assign('tsAjax', $tsAjax); if ($tsAjax) { // if status is enabled, need to adjust field index by -1 - need to check both - tracker config and plugin config $adjustCol = isset($showstatus) && $showstatus == 'y' && $definition->isEnabled('showStatus') ? -1 : 0; //convert tablesorter filter syntax to tiki syntax if (!empty($_REQUEST['filter'])) { $i = 0; $tsfiltersArray = explode('|', $tsfilters); foreach ($_REQUEST['filter'] as $col => $ajaxfilter) { $fieldtype = $allfields['data'][$col + $adjustCol]['type']; $id = $allfields['data'][$col + $adjustCol]['fieldId']; //handle status filter if ($adjustCol === -1 && $col === 0 && in_array($ajaxfilter, ['o', 'p', 'c'])) { $status = $ajaxfilter; /* * handle date filter - these are always one filter, in the form of: * from: >=1427389832000; to: <=1427389832000; both from and to: 1427389832000 - 1427880000000 * which is unix timestamp in milliseconds */ } elseif (strpos($tsfiltersArray[$col], 'type:date') !== false && in_array($fieldtype, ['f', 'j'])) { $datefilter = explode(' - ', $ajaxfilter); $filterfield[$i] = $id; //a range (from and to filters) will have 2 items in the array if (count($datefilter) == 2) { $filterfield[$i + 1] = $id; //use substr to leave off milliseconds since date is stored in seconds in the database $exactvalue[$i] = 'greaterequal(@' . substr($datefilter[0], 0, 10) . ')'; $exactvalue[$i + 1] = 'lessequal(@' . substr($datefilter[1], 0, 10) . ')'; } else { //use substr to leave off milliseconds since date is stored in seconds in the database $stamp = '(@' . substr($datefilter[0], 2, 10) . ')'; $symbol = substr($datefilter[0], 0, 2); if ($symbol === '<=') { $compare = 'lessequal'; } elseif ($symbol === '>=') { $compare = 'greaterequal'; } $exactvalue[$i] = $compare . $stamp; } } else { $filterfield[$i] = $id; //convert category filters entered as text if ($fieldtype === 'e' && !is_numeric($ajaxfilter)) { $categlib = TikiLib::lib('categ'); $ajaxfilter = $categlib->get_category_id($ajaxfilter); } $filtervalue[$i] = $ajaxfilter; } $i++; } } //convert tablesorter sort syntax to tiki syntax if (!empty($_REQUEST['sort'])) { foreach ($_REQUEST['sort'] as $sortcol => $ajaxsort) { if ($ajaxsort == '0') { $dir = '_asc'; } elseif ($ajaxsort == '1') { $dir = '_desc'; } //avoid setting sort_mode based on status field - will return error. Handle later once records are retrieved if ($adjustCol !== -1 || $sortcol !== 0) { $sort_mode = 'f_' . $allfields['data'][$sortcol + $adjustCol]['fieldId'] . $dir; } } } //set max records if (isset($_REQUEST['numrows'])) { $max = $_REQUEST['numrows']; } } /*** end first tablesorter section ***/ if (!empty($filterfield)) { if (is_array($filterfield)) { foreach ($filterfield as $ff) { unset($filterfieldok); if (is_array($ff)) { // already checked in trackerfilter $filterfieldok = true; break; } else { foreach ($allfields['data'] as $f) { if ($f['fieldId'] == $ff) { $filterfieldok = true; break; } } } if (!isset($filterfieldok)) { break; } } } else { foreach ($allfields['data'] as $f) { if ($f['fieldId'] == $filterfield) { $filterfieldok = true; break; } } } if (!isset($filterfieldok)) { return tra('incorrect filterfield'); } } $filter = array(); if (isset($periodQuantity)) { switch ($periodUnit) { case 'hour': $periodUnit = 3600; break; case 'day': $periodUnit = 86400; break; case 'week': $periodUnit = 604800; break; case 'month': $periodUnit = 2628000; break; default: break; } if (!isset($periodType)) { $periodType = 'c'; } if (is_int($periodUnit) && $periodType == 'm') { $filter['lastModifAfter'] = $tikilib->now - $periodQuantity * $periodUnit; $filter['lastModifBefore'] = $tikilib->now; } elseif (is_int($periodUnit)) { # case for periodType beig c or anything else (therefore, set as case for default) $filter['createdAfter'] = $tikilib->now - $periodQuantity * $periodUnit; $filter['createdBefore'] = $tikilib->now; } } if (isset($_REQUEST['reloff']) && empty($_REQUEST['itemId']) && !empty($_REQUEST['trackerId'])) { //coming from a pagination $items = $trklib->list_items($_REQUEST['trackerId'], $_REQUEST['reloff'], 1, '', '', isset($_REQUEST['filterfield']) ? preg_split('/\\s*:\\s*/', $_REQUEST['filterfield']) : '', isset($_REQUEST['filtervalue']) ? preg_split('/\\s*:\\s*/', $_REQUEST['filtervalue']) : '', isset($_REQUEST['status']) ? preg_split('/\\s*:\\s*/', $_REQUEST['status']) : '', isset($_REQUEST['initial']) ? $_REQUEST['initial'] : '', isset($_REQUEST['exactvalue']) ? preg_split('/\\s*:\\s*/', $_REQUEST['exactvalue']) : '', $filter); if (isset($items['data'][0]['itemId'])) { $_REQUEST['cant'] = $items['cant']; $_REQUEST['itemId'] = $items['data'][0]['itemId']; } } if (!empty($_REQUEST['itemId']) && $tiki_p_tracker_vote_ratings == 'y' && $user) { $hasVoted = false; foreach ($allfields['data'] as $f) { if ($f['type'] == 's' && $definition->isEnabled('useRatings') && ($f['name'] == 'Rating' || ($f['name'] = tra('Rating')))) { $i = $f['fieldId']; if (isset($_REQUEST["ins_{$i}"]) && ($_REQUEST["ins_{$i}"] == 'NULL' || in_array($_REQUEST["ins_{$i}"], explode(',', $tracker_info['ratingOptions'])))) { $trklib->replace_rating($trackerId, $_REQUEST['itemId'], $i, $user, $_REQUEST["ins_{$i}"]); $hasVoted = true; } } elseif ($f['type'] == '*' || $f['type'] == 'STARS') { $i = $f['fieldId']; if (isset($_REQUEST["ins_{$i}"])) { $trklib->replace_star($_REQUEST["ins_{$i}"], $trackerId, $_REQUEST['itemId'], $f, $user); $hasVoted = true; } } } if ($hasVoted) { // Must strip NULL for remove my vote case $url = preg_replace('/[(\\?)|&]vote=y/', '$1', preg_replace('/[(\\?)|&]ins_[0-9]+=-?[0-9|N|U|L]*/', '$1', $_SERVER['REQUEST_URI'])); // reduce duplicate itemIds in query string $occurences = preg_match_all('/[(\\?)|&]itemId=[0-9]+/', $url, $matches); if ($params['list_mode'] == 'y' && $occurences > 0) { $url = preg_replace('/[(\\?)|&]itemId=[0-9]+/', '$1', $url, $occurences); } elseif ($occurences > 1) { $url = preg_replace('/&itemId=[0-9]+/', '', $url, $occurences - 1); } header("Location: {$url}"); die; } } if (!empty($showwatch) && $showwatch == 'y' && $prefs['feature_user_watches'] == 'y' && $tiki_p_watch_trackers == 'y' && !empty($user)) { if (isset($_REQUEST['watch']) && isset($_REQUEST['trackerId']) && $_REQUEST['trackerId'] == $trackerId) { if ($_REQUEST['watch'] == 'add') { $tikilib->add_user_watch($user, 'tracker_modified', $trackerId, 'tracker', $tracker_info['name'], "tiki-view_tracker.php?trackerId=" . $trackerId); } elseif ($_REQUEST['watch'] == 'stop') { $tikilib->remove_user_watch($user, 'tracker_modified', $trackerId, 'tracker'); } } if ($tikilib->user_watches($user, 'tracker_modified', $trackerId, 'tracker')) { $smarty->assign('user_watching_tracker', 'y'); } else { $smarty->assign('user_watching_tracker', 'n'); } } else { $smarty->clear_assign('user_watching_tracker'); } if (empty($showrss) || $showrss == 'n') { $smarty->assign('showrss', 'n'); } else { $smarty->assign('showrss', 'y'); } if (empty($listfields)) { foreach ($allfields['data'] as $f) { $listfields[] = $f['fieldId']; } } if (!empty($popup)) { $popupfields = $popup; } else { $popupfields = array(); } $smarty->assign_by_ref('tracker_info', $tracker_info); //$query_array = array(); //$quarray = array(); //TikiLib::parse_str($_SERVER['QUERY_STRING'],$query_array); if (isset($stickypopup) && $stickypopup == 'y') { $stickypopup = true; } else { $stickypopup = false; } $smarty->assign_by_ref('stickypopup', $stickypopup); if (!isset($showtitle)) { $showtitle = 'n'; } $smarty->assign_by_ref('showtitle', $showtitle); if (!isset($showlinks)) { $showlinks = 'n'; } $smarty->assign_by_ref('showlinks', $showlinks); if (!isset($showdesc)) { $showdesc = 'n'; } $smarty->assign_by_ref('showdesc', $showdesc); if (!isset($showinitials)) { $showinitials = 'n'; } $smarty->assign_by_ref('showinitials', $showinitials); if (!isset($shownbitems)) { $shownbitems = 'n'; } $smarty->assign_by_ref('shownbitems', $shownbitems); if (!isset($showstatus)) { $showstatus = 'n'; } $smarty->assign_by_ref('showstatus', $showstatus); if (!isset($showfieldname)) { $showfieldname = 'y'; } $smarty->assign_by_ref('showfieldname', $showfieldname); if (!isset($showitemrank)) { $showitemrank = 'n'; } $smarty->assign_by_ref('showitemrank', $showitemrank); if (!isset($showdelete)) { $showdelete = 'n'; } $smarty->assign_by_ref('showdelete', $showdelete); if (!isset($showpenditem)) { $showpenditem = 'n'; } $smarty->assign_by_ref('showpenditem', $showpenditem); if (!isset($showcloseitem)) { $showcloseitem = 'n'; } $smarty->assign_by_ref('showcloseitem', $showcloseitem); if (!isset($showopenitem)) { $showopenitem = 'n'; } $smarty->assign_by_ref('showopenitem', $showopenitem); if (!isset($showpagination)) { $showpagination = 'y'; } $smarty->assign_by_ref('showpagination', $showpagination); if (!isset($sortchoice)) { $sortchoice = ''; } else { foreach ($sortchoice as $i => $sc) { $sc = explode('|', $sc); $sortchoice[$i] = array('value' => $sc[0], 'label' => empty($sc[1]) ? $sc[0] : $sc[1]); } } $smarty->assign_by_ref('sortchoice', $sortchoice); if (!isset($status)) { $status = 'o'; } $tr_status = $status; $smarty->assign_by_ref('tr_status', $tr_status); if (!isset($list_mode)) { $list_mode = 'y'; } $smarty->assign_by_ref('list_mode', $list_mode); if (!isset($showcreated)) { $showcreated = $tracker_info['showCreated']; } $smarty->assign_by_ref('showcreated', $showcreated); if (!isset($showlastmodif)) { $showlastmodif = $tracker_info['showLastModif']; } $smarty->assign_by_ref('showlastmodif', $showlastmodif); if (!isset($showlastmodifby)) { $showlastmodifby = $tracker_info['showLastModifBy']; } $smarty->assign_by_ref('showlastmodifby', $showlastmodifby); if (!isset($more)) { $more = 'n'; } $smarty->assign_by_ref('more', $more); if (!isset($moreurl)) { $moreurl = 'tiki-view_tracker.php'; } $smarty->assign_by_ref('moreurl', $moreurl); if (!isset($url)) { $url = ''; } $smarty->assign_by_ref('url', $url); if (!isset($export)) { $export = 'n'; } $smarty->assign_by_ref('export', $export); if (!empty($ldelim)) { $smarty->left_delimiter = $ldelim; } if (!empty($rdelim)) { $smarty->right_delimiter = $rdelim; } if (isset($checkbox)) { $check = array('ix' => -1, 'type' => 'checkbox'); $cb = explode('/', $checkbox); if (isset($cb[0])) { $check['fieldId'] = $cb[0]; } if (isset($cb[1])) { $check['name'] = $cb[1]; } if (isset($cb[2])) { $check['title'] = $cb[2]; } if (isset($cb[3])) { $check['submit'] = $cb[3]; } if (isset($cb[4])) { $check['action'] = $cb[4]; } if (isset($cb[5])) { $check['tpl'] = $cb[5]; } if (isset($cb[6]) && $cb[6] == 'radio') { $check['radio'] = 'y'; $check['type'] = 'radio'; } if (isset($cb[6]) && $cb[6] == 'dropdown') { $check['dropdown'] = 'y'; } // is this actually used? $smarty->assign_by_ref('checkbox', $check); } if (isset($_REQUEST["tr_sort_mode{$iTRACKERLIST}"])) { $sort_mode = $_REQUEST["tr_sort_mode{$iTRACKERLIST}"]; } elseif (!isset($sort_mode)) { if (!empty($tracker_info['defaultOrderKey'])) { if ($tracker_info['defaultOrderKey'] == -1) { $sort_mode = 'lastModif'; } elseif ($tracker_info['defaultOrderKey'] == -2) { $sort_mode = 'created'; } elseif ($tracker_info['defaultOrderKey'] == -3) { $sort_mode = 'itemId'; } else { $sort_mode = 'f_' . $tracker_info['defaultOrderKey']; } if (isset($tracker_info['defaultOrderDir'])) { $sort_mode .= "_" . $tracker_info['defaultOrderDir']; } else { $sort_mode .= "_asc"; } } else { $sort_mode = ''; } } elseif ($sort_mode != 'created_asc' && $sort_mode != 'lastModif_asc' && $sort_mode != 'created_desc' && $sort_mode != 'lastModif_desc' && !preg_match('/f_[0-9]+_(asc|desc)/', $sort_mode)) { return tra('Incorrect param') . ' sort_mode'; } $tr_sort_mode = $sort_mode; $smarty->assign_by_ref('tr_sort_mode', $tr_sort_mode); if (!isset($max)) { $max = $prefs['maxRecords']; } if (isset($_REQUEST["tr_offset{$iTRACKERLIST}"]) && (!isset($forceoffset) || $forceoffset == 'n')) { $tr_offset = $_REQUEST["tr_offset{$iTRACKERLIST}"]; } else { if (isset($offset) && $offset >= 0) { $tr_offset = $offset; } else { $tr_offset = 0; } } $smarty->assign_by_ref("tr_offset{$iTRACKERLIST}", $tr_offset); $tr_initial = ''; if ($showinitials == 'y') { if (isset($_REQUEST['tr_initial'])) { //$query_array['tr_initial'] = $_REQUEST['tr_initial']; $tr_initial = $_REQUEST['tr_initial']; } $smarty->assign('initials', explode(' ', 'a b c d e f g h i j k l m n o p q r s t u v w x y z')); } $smarty->assign_by_ref('tr_initial', $tr_initial); if (isset($view) && $view == 'user' || isset($view_user) || isset($_REQUEST['tr_user'])) { if ($f = $definition->getAuthorField()) { $filterfield[] = $f; $filtervalue[] = ''; if (!isset($_REQUEST['tr_user'])) { $exactvalue[] = isset($view) ? empty($user) ? 'Anonymous' : $user : $view_user; } else { $exactvalue[] = $_REQUEST['tr_user']; $smarty->assign_by_ref('tr_user', $exactvalue); } if ($definition->isEnabled('writerCanModify') or $definition->isEnabled('userCanSeeOwn')) { $skip_status_perm_check = true; } } } if (isset($view) && $view == 'page' && isset($_REQUEST['page'])) { if ($f = $trklib->get_page_field($trackerId)) { $filterfield[] = $f['fieldId']; $filtervalue[] = ''; $exactvalue[] = $_REQUEST['page']; } } if (isset($view) && $view == 'ip') { if ($f = $definition->getAuthorIpField()) { $filterfield[] = $f; $filtervalue[] = ''; $ip = $tikilib->get_ip_address(); $exactvalue[] = $ip; } } if (!isset($filtervalue)) { $filtervalue = ''; } else { foreach ($filtervalue as $i => $f) { if ($f == '#user') { $filtervalue[$i] = $user; } else { if ($f == '#default_group') { $filtervalue[$i] = $_SESSION['u_info']['group']; } } } } if (!isset($exactvalue)) { $exactvalue = ''; } else { foreach ($exactvalue as $i => $f) { if ($f == '#user') { $exactvalue[$i] = $user; } } } if (!empty($_REQUEST['itemId']) && (empty($ignoreRequestItemId) || $ignoreRequestItemId != 'y')) { $itemId = $_REQUEST['itemId']; } if (isset($itemId)) { if (is_string($itemId) && strstr($itemId, ':')) { // JB Tiki7: This doesn't quite make sense as itemId is an array $itemId = explode(':', $itemId); // Probably just some redundant code TOKIL } $filter['tti.`itemId`'] = $itemId; } $newItemRateField = false; $status_types = $trklib->status_types(); $smarty->assign('status_types', $status_types); if (!isset($filterfield)) { $filterfield = ''; } else { if (!empty($filterfield)) { if (!empty($filtervalue)) { $fvs = $filtervalue; unset($filtervalue); for ($i = 0, $count_ff = count($filterfield); $i < $count_ff; ++$i) { $filtervalue[] = isset($fvs[$i]) ? $fvs[$i] : ''; } } if (!empty($exactvalue)) { $evs = $exactvalue; unset($exactvalue); for ($i = 0, $count_ff2 = count($filterfield); $i < $count_ff2; ++$i) { if (isset($evs[$i])) { if (is_array($evs[$i])) { // already processed $exactvalue[] = $evs[$i]; } elseif (preg_match('/(not)?categories\\(([0-9]+)\\)/', $evs[$i], $matches)) { $categlib = TikiLib::lib('categ'); if (ctype_digit($matches[2]) && $matches[2] > 0) { $cfilter = array('identifier' => $matches[2], 'type' => 'descendants'); } else { $cfilter = NULL; } $categs = $categlib->getCategories($cfilter, true, false); $l = array($matches[2]); foreach ($categs as $cat) { $l[] = $cat['categId']; } if (empty($matches[1])) { $exactvalue[] = $l; } else { $exactvalue[] = array('not' => $l); } } elseif (preg_match('/(not)?preference\\((.*)\\)/', $evs[$i], $matches)) { if (empty($matches[1])) { $exactvalue[] = $prefs[$matches[2]]; } else { $exactvalue[] = array('not' => $prefs[$matches[2]]); } } elseif (preg_match('/(not)?field\\(([0-9]+)(,([0-9]+|user)(,([0-9]+))?)?\\)/', $evs[$i], $matches)) { // syntax field(fieldId, user, trackerId) or field(fieldId)(need the REQUEST['itemId'] or field(fieldId, itemId) or field(fieldId, user) if (empty($matches[4]) && !empty($_REQUEST['itemId'])) { // user the itemId of the url $matches[4] = $_REQUEST['itemId']; } if (!empty($matches[4]) && $matches[4] == 'user') { if (!empty($matches[6])) { // pick the user item of this tracker $t_i = $trklib->get_tracker($matches[6]); $matches[4] = $trklib->get_user_item($matches[6], $t_i, $user); } elseif ($prefs['userTracker'] == 'y') { //pick the generic user tracker $utid = $userlib->get_tracker_usergroup($user); $matches[4] = $trklib->get_item_id($utid['usersTrackerId'], $utid['usersFieldId'], $user); } } if (!empty($matches[4])) { $l = $trklib->get_item_value(0, $matches[4], $matches[2]); $field = $trklib->get_tracker_field($matches[2]); if ($field['type'] == 'r') { $refItemId = $l; $l = $trklib->get_item_value($field['options_array'][0], $refItemId, $field['options_array'][3]); } } if (empty($matches[1])) { $exactvalue[] = $l; } else { $exactvalue[] = array('not' => $l); } } elseif (preg_match('/(less|greater|lessequal|greaterequal)\\((.+)\\)/', $evs[$i], $matches)) { $conv = array('less' => '<', 'greater' => '>', 'lessequal' => '<=', 'greaterequal' => '>='); $field = $trklib->get_tracker_field($filterfield[$i]); if ($field['type'] == 'f' || $field['type'] == 'j') { if ($matches[2] == 'now') { $matches[2] = $tikilib->now; } elseif (($r = strtotime($matches[2])) !== false) { $matches[2] = $r; } } $exactvalue[] = array($conv[$matches[1]] => $matches[2]); } elseif (preg_match('/not\\((.+)\\)/', $evs[$i], $matches)) { $exactvalue[] = array('not' => $matches[1]); } else { $exactvalue[] = $evs[$i]; } } else { $exactvalue[] = ''; } } } } } if ($tiki_p_admin_trackers != 'y' && $perms['tiki_p_view_trackers'] != 'y' && ($definition->isEnabled('writerCanModify') or $definition->isEnabled('userCanSeeOwn')) && $user && $userCreatorFieldId) { //patch this should be in list_items if ($filterfield != $userCreatorFieldId || is_array($filterfield) && !in_array(${$userCreatorFieldId}, $filterfield)) { if (is_array($filterfield)) { $filterfield[] = $userCreatorFieldId; } elseif (empty($filterfield)) { $filterfield = $userCreatorFieldId; } else { $filterfield = array($filterfield, $fieldId); } if (is_array($exactvalue)) { $exactvalue[] = $user; } elseif (empty($exactvalue)) { $exactvalue = $user; } else { $exactvalue = array($exactvalue, $user); } } } if ($tiki_p_admin_trackers != 'y' && $perms['tiki_p_view_trackers'] != 'y' && $user && $groupCreatorFieldId) { if ($filterfield != $groupCreatorFieldId || is_array($filterfield) && !in_array($groupCreatorFieldId, $filterfield)) { $groups = $userlib->get_user_groups($user); if (is_array($filterfield)) { $filterfield[] = $groupCreatorFieldId; } elseif (empty($filterfield)) { $filterfield = $groupCreatorFieldId; } else { $filterfield = array($filterfield, $fieldId); } if (is_array($exactvalue)) { $exactvalue[] = array_merge($exactvalue, $groups); } elseif (empty($exactvalue)) { $exactvalue = $groups; } else { $exactvalue = array_merge(array($exactvalue), $groups); } global $group; // awful trick - but the filter garantee that the group is ok $smarty->assign_by_ref('ours', $group); $perms = array_merge($perms, $trklib->get_special_group_tracker_perm($tracker_info)); } } for ($i = 0, $count_allf = count($allfields['data']); $i < $count_allf; $i++) { if ($allfields['data'][$i]['type'] == 'C') { $infoComputed = $trklib->get_computed_info($allfields['data'][$i]['options_array'][0], $trackerId, $allfields['data']); if (!empty($infoComputed)) { $allfields['data'][$i] = array_merge($infoComputed, $allfields['data'][$i]); } } elseif ($allfields["data"][$i]['type'] == 'w') { /* keep track of dynamic list items referring to user selectors */ $refFieldId = $allfields["data"][$i]['options_array'][3]; $refField = $trklib->get_tracker_field($refFieldId); if ($refField['type'] == 'u') { $allfields["data"][$i]['type'] = $refField['type']; } } // If listfields is a colon separated string, convert it to an array if (!is_array($listfields)) { $listfields = explode(':', $listfields); } if ((in_array($allfields["data"][$i]['fieldId'], $listfields) or in_array($allfields["data"][$i]['fieldId'], $popupfields)) and $allfields["data"][$i]['isPublic'] == 'y') { $passfields["{$allfields["data"][$i]['fieldId']}"] = $allfields["data"][$i]; } if (isset($check['fieldId']) && $allfields["data"][$i]['fieldId'] == $check['fieldId']) { $passfields["{$allfields["data"][$i]['fieldId']}"] = $allfields["data"][$i]; if (!in_array($allfields["data"][$i]['fieldId'], $listfields)) { $allfields["data"][$i]['isPublic'] == 'n'; } //don't show it $check['ix'] = count($passfields) - 1; } if ($allfields["data"][$i]['name'] == 'page' && empty($filterfield) && empty($displayList) && !empty($view) && $view == 'page') { $filterfield = $allfields["data"][$i]['fieldId']; $filtervalue = $_REQUEST['page']; } if ($definition->isEnabled('useRatings') and $allfields["data"][$i]['type'] == 's' and $allfields["data"][$i]['name'] == 'Rating') { $newItemRateField = $allfields["data"][$i]['fieldId']; } } $nonPublicFieldsWarning = ''; if ($tiki_p_edit === 'y') { foreach ($allfields['data'] as $field) { if ($field['isPublic'] !== 'y' && in_array($field['fieldId'], array_merge($listfields, $popupfields))) { $nonPublicFieldsWarning = tra('You have attempted to view data of a tracker field which is not public. You need to ask the admin to change the setting to public for this field.'); } } } if ($editableall == 'y') { $editable = $listfields; } $smarty->assign('nonPublicFieldsWarning', $nonPublicFieldsWarning); $smarty->assign_by_ref('filterfield', $filterfield); $smarty->assign_by_ref('filtervalue', $filtervalue); $smarty->assign_by_ref('fields', $passfields); $smarty->assign_by_ref('exactvalue', $exactvalue); $smarty->assign_by_ref('listfields', $listfields); $smarty->assign_by_ref('popupfields', $popupfields); $smarty->assign('editableFields', $editable); if (!empty($filterfield)) { $urlquery['filterfield'] = is_array($filtervalue) ? implode(':', $filterfield) : $filterfield; if (!is_array($filtervalue)) { $filtervalue = array($filtervalue); } $urlquery['filtervalue'] = is_array($filtervalue) ? implode(':', $filtervalue) : $filtervalue; $urlquery['exactvalue'] = is_array($exactvalue) ? implode(':', $exactvalue) : $exactvalue; $urlquery['trackerId'] = $trackerId; $smarty->assign('urlquery', $urlquery); } else { $smarty->assign('urlquery', ''); } if (!empty($export) && $export != 'n' && $perms['tiki_p_export_tracker'] == 'y') { $smarty->loadPlugin('smarty_function_service'); $exportParams = array('controller' => 'tracker', 'action' => 'export', 'trackerId' => $trackerId); if (!empty($fields)) { $exportParams['displayedFields'] = is_array($fields) ? implode(':', $fields) : $fields; } if (is_array($filterfield)) { foreach ($filterfield as $i => $fieldId) { $exportParams["f_{$fieldId}"] = empty($filtervalue[$i]) ? $exactvalue[$i] : $filtervalue[$i]; } } elseif (!empty($filterfield)) { $exportParams["f_{$filterfield}"] = empty($filtervalue) ? $exactvalue : $filtervalue; } $exportUrl = smarty_function_service($exportParams, $smarty); $smarty->assign('exportUrl', $exportUrl); } if (!empty($_REQUEST['delete'])) { $itemToDelete = Tracker_Item::fromId($_REQUEST['delete']); if ($itemToDelete->canRemove()) { $trklib->remove_tracker_item($_REQUEST['delete']); } if (!empty($urlafterdelete)) { header("Location: {$urlafterdelete}"); exit; } } if (!empty($_REQUEST['closeitem'])) { $itemToModify = Tracker_Item::fromId($_REQUEST['closeitem']); if ($itemToModify->canModify()) { $trklib->change_status(array(array('itemId' => $_REQUEST['closeitem'])), 'c'); } } if (!empty($_REQUEST['penditem'])) { $itemToModify = Tracker_Item::fromId($_REQUEST['penditem']); if ($itemToModify->canModify()) { $trklib->change_status(array(array('itemId' => $_REQUEST['penditem'])), 'p'); } } if (!empty($_REQUEST['openitem'])) { $itemToModify = Tracker_Item::fromId($_REQUEST['openitem']); if ($itemToModify->canModify()) { $trklib->change_status(array(array('itemId' => $_REQUEST['openitem'])), 'o'); } } if (!empty($calendarfielddate)) { $calendarlib = TikiLib::lib('calendar'); $focusDate = empty($_REQUEST['todate']) ? $tikilib->now : $_REQUEST['todate']; $focus = $calendarlib->infoDate($focusDate); if (!empty($calendardelta)) { if ($calendardelta[0] == '-') { $focus = $calendarlib->focusPrevious($focus, str_replace('-', '', $calendardelta)); } else { $focus = $calendarlib->focusNext($focus, str_replace('+', '', $calendardelta)); } } $calendarlib->focusStartEnd($focus, $calendarviewmode, $calendarbeginmonth, $startPeriod, $startNextPeriod); $cell = $calendarlib->getTableViewCells($startPeriod, $startNextPeriod, $calendarviewmode, $calendarlib->firstDayofWeek($user)); if (is_array($filterfield) == false) { $filterfield = array($filterfield); } if (is_array(${$filtervalue}) == false) { $filtervalue = array($filtervalue); } $filterfield[] = $calendarfielddate[0]; $filtervalue[] = ''; $exactvalue[] = array('>=' => $startPeriod['date']); $filterfield[] = empty($calendarfielddate[1]) ? $calendarfielddate[0] : $calendarfielddate[1]; $filtervalue[] = ''; $exactvalue[] = array('<' => $startNextPeriod['date']); } if (count($passfields)) { // Optimization: Group category fields using AND logic indicated by sub-array $catfilters = array(); $catfiltervalue = array(); $catfilternotvalue = array(); if (!empty($filterfield)) { foreach ($filterfield as $k => $ff) { $filterfieldinfo = $trklib->get_tracker_field($ff); if ($filterfieldinfo['type'] == 'e') { $catfilters[] = $k; if (!empty($filtervalue[$k]) && empty($exactvalue[$k])) { // Some people use filtervalue instead of exactvalue for category filters $exactvalue[$k] = $filtervalue[$k]; for ($i = 0; $i < $k; $i++) { if (!isset($exactvalue[$i])) { $exactvalue[$i] = ''; } } } if (array_key_exists('not', array($exactvalue[$k]))) { $catfilternotfield[0] = $ff; $catfilternotvalue[] = array($exactvalue[$k]); } else { $catfilterfield[0] = $ff; $catfiltervalue[] = array($exactvalue[$k]); } } } } if ($catfilters) { foreach ($catfilters as $cf) { unset($filterfield[$cf]); unset($exactvalue[$cf]); } if ($catfiltervalue) { // array_merge is used because it reindexes $filterfield = array_merge($filterfield, $catfilterfield); $exactvalue = array_merge($exactvalue, array($catfiltervalue)); } if ($catfilternotvalue) { $filterfield = array_merge($filterfield, $catfilternotfield); $exactvalue[] = array('not' => $catfilternotvalue); } } // End Optimization //fetch tracker items $items = $trklib->list_items($trackerId, $tr_offset, $max, $tr_sort_mode, $passfields, !empty($calendarfielddate) ? null : $filterfield, $filtervalue, $tr_status, $tr_initial, $exactvalue, $filter, $allfields, $skip_status_perm_check); /*** tablesorter ***/ if ($tsOn && !$tsAjax) { // when using serverside filtering check wether a dropdown is in use // and we must take params from tracker definition because no explicit options have been defined if ($tsServer) { //format from plugin: type:text|type:dropdown;option:1=Open;option:2=Closed|type:text|type:nofilter|type:nofilter|type:nofilter if (!empty($tsfilters) && strpos($tsfilters, 'dropdown') !== false) { $tsfiltersArray = explode('|', $tsfilters); $adjustCol = isset($showstatus) && $showstatus == 'y' && $definition->isEnabled('showStatus') ? -1 : 0; foreach ($tsfiltersArray as $col => &$tsfilterField) { // only consider dropdown definitions without explicit option if (strpos($tsfilterField, 'dropdown') !== false && strpos($tsfilterField, 'option') === false) { //content from options (json object): {"options":["1=Open"," 2=Closed]} - note there can be whitespaces - it should not but there can be - yet another fix required if ($allfields['data'][$col + $adjustCol]['type'] == 'd') { $options = $allfields['data'][$col + $adjustCol]['options']; $options = json_decode($options); $options = $options->options; // construct the new dropdown filterfield entry from the trackerfield definition $newTsfilterField = 'type:dropdown'; foreach ($options as $option) { $newTsfilterField .= ";option:" . trim($option); } // update field - note that we used a ref $tsfilterField = $newTsfilterField; } } } // update tsfilters $tsfilters = implode('|', $tsfiltersArray); } } $ts_id = 'wptrackerlist' . $trackerId . '-' . $iTRACKERLIST; $ts = new Table_Plugin(); $ts->setSettings($ts_id, isset($server) ? $server : null, $sortable, isset($sortList) ? $sortList : null, isset($tsortcolumns) ? $tsortcolumns : null, isset($tsfilters) ? $tsfilters : null, isset($tsfilteroptions) ? $tsfilteroptions : null, isset($tspaginate) ? $tspaginate : null, isset($tscolselect) ? $tscolselect : null, $GLOBALS['requestUri'], $items['cant'], isset($tstotals) ? $tstotals : null, isset($tstotalformat) ? $tstotalformat : null, isset($tstotaloptions) ? $tstotaloptions : null); //loads the jquery tablesorter code if (is_array($ts->settings)) { $ts->settings['ajax']['offset'] = 'tr_offset' . $iTRACKERLIST; Table_Factory::build('PluginWithAjax', $ts->settings); } } //determine whether totals will be added to bottom of table if (isset($ts->settings)) { Table_Totals::setTotals($ts->settings); } //handle certain tablesorter sorts if (isset($sortcol) && $items['cant'] > 1) { $fieldtype = $items['data'][0]['field_values'][$sortcol + $adjustCol]['type']; //convert categoryId sort to category name sort when tablesorter server side sorting is used if ($fieldtype === 'e') { foreach ($items['data'] as $key => $record) { $catfield = $record['field_values'][$sortcol + $adjustCol]; $sortarray[$key] = $catfield['list'][$catfield['value']]['name']; } //sort status } elseif ($adjustCol === -1 && $sortcol === 0) { $sortarray = array_column($items['data'], 'status'); } array_multisort($sortarray, $dir == '_desc' ? SORT_DESC : SORT_ASC, $items['data']); } /*** end second tablesorter section ***/ if (isset($silent) && $silent == 'y' && empty($items['cant'])) { return; } if (isset($items['cant']) && $items['cant'] == 1 && isset($goIfOne) && ($goIfOne == 'y' || $goIfOne == 1)) { header('Location: tiki-view_tracker_item.php?itemId=' . $items['data'][0]['itemId'] . '&trackerId=' . $items['data'][0]['trackerId']); die; } if ($newItemRateField && !empty($items['data'])) { foreach ($items['data'] as $f => $v) { $items['data'][$f]['my_rate'] = $tikilib->get_user_vote("tracker." . $trackerId . '.' . $items['data'][$f]['itemId'], $user); } } if (!empty($items['data']) && ($definition->isEnabled('useComments') && $definition->isEnabled('showComments') || $definition->isEnabled('showLastComment'))) { foreach ($items['data'] as $itkey => $oneitem) { if ($definition->isEnabled('showComments')) { $items['data'][$itkey]['comments'] = $trklib->get_item_nb_comments($items['data'][$itkey]['itemId']); } if ($definition->isEnabled('showLastComment')) { $l = $trklib->list_last_comments($items['data'][$itkey]['trackerId'], $items['data'][$itkey]['itemId'], 0, 1); $items['data'][$itkey]['lastComment'] = !empty($l['cant']) ? $l['data'][0] : ''; } } } if (!empty($items['data']) && ($definition->isEnabled('useAttachments') && $definition->isEnabled('showAttachments'))) { foreach ($items["data"] as $itkey => $oneitem) { $res = $trklib->get_item_nb_attachments($items["data"][$itkey]['itemId']); $items["data"][$itkey]['attachments'] = $res['attachments']; } } if (!empty($compute) && !empty($items['data'])) { $fs = preg_split('/ *: */', $compute); foreach ($fs as $fieldId) { if (strstr($fieldId, "/")) { list($fieldId, $oper) = preg_split('/ *\\/ */', $fieldId); $oper = strtolower($oper); if ($oper == 'average') { $oper = 'avg'; } elseif ($oper != 'sum' && $oper != 'avg') { $oper = 'sum'; } } else { $oper = 'sum'; } foreach ($items['data'] as $i => $item) { foreach ($item['field_values'] as $field) { if ($field['fieldId'] == $fieldId) { if (preg_match('/^ *$/', $field['value']) || !is_numeric($field['value'])) { $amount[$i] = '0'; } else { $amount[$i] = $field['value']; } break; } } } $value = array_sum($amount); if ($oper == 'avg') { $value = round($value / count($amount)); } $computedFields[$fieldId][] = array_merge(array('computedtype' => 'n', 'operator' => $oper, 'value' => $value), $passfields[$fieldId]); } $smarty->assign_by_ref('computedFields', $computedFields); } else { $smarty->assign('computedFields', ''); } if (!empty($calendarfielddate)) { foreach ($items['data'] as $i => $item) { if (!empty($wiki)) { $smarty->assign('fields', $item['field_values']); $smarty->assign('item', $item); $smarty->assign('wiki', "wiki:{$wiki}"); $smarty->assign('showpopup', 'n'); $items['data'][$i]['over'] = $smarty->fetch('tracker_pretty_item.tpl'); } if (!empty($tplwiki)) { $smarty->assign('fields', $item['field_values']); $smarty->assign('item', $item); $smarty->assign('wiki', "tplwiki:{$tplwiki}"); $smarty->assign('showpopup', 'n'); $items['data'][$i]['over'] = $smarty->fetch('tracker_pretty_item.tpl'); } if (empty($items['data'][$i]['over'])) { $items['data'][$i]['over'] = $trklib->get_isMain_value($trackerId, $item['itemId']); } $items['data'][$i]['visible'] = 'y'; } $trklib->fillTableViewCell($items['data'], $calendarfielddate, $cell); $smarty->assign('cell', $cell); $smarty->assign('show_calendar_module', 'y'); $calendarlib->getDayNames($calendarlib->firstDayofWeek($user), $daysnames, $daysnames_abr); $smarty->assign('daysnames_abr', $daysnames_abr); $smarty->assign('focusmonth', TikiLib::date_format("%m", $focusDate)); $smarty->assign('module_params', array('viewmode' => 'n', 'showaction' => 'n', 'notitle' => empty($calendartitle) ? 'y' : 'n', 'title' => $calendartitle, 'viewnavbar' => $calendarviewnavbar, 'decorations' => empty($calendartitle) ? 'n' : 'y')); $smarty->assign('tpl_module_title', tra($calendartitle)); $smarty->assign('now', $tikilib->now); $smarty->assign('calendarViewMode', $calendarviewmode); $smarty->assign('viewmodelink', $calendarviewmode); $smarty->assign('viewmode', $calendarviewmode); $focus_prev = $calendarlib->focusPrevious($focus, $calendarviewmode); $smarty->assign('focus_prev', $focus_prev['date']); $focus_next = $calendarlib->focusNext($focus, $calendarviewmode); $smarty->assign('focus_next', $focus_next['date']); $smarty->assign('daystart', $startPeriod['date']); $dayend = $calendarlib->infoDate($startNextPeriod['date'] - 1); $smarty->assign('dayend', $dayend['date']); $smarty->assign('today', TikiLib::make_time(0, 0, 0, TikiLib::date_format('%m'), TikiLib::date_format('%d'), TikiLib::date_format('%Y'))); $smarty->assign('sticky_popup', $calendarstickypopup); $smarty->assign('calendar_popup', $calendarpopup); $smarty->assign('showpopup', 'n'); $headerlib = TikiLib::lib('header'); $headerlib->add_cssfile('themes/base_files/feature_css/calendar.css', 20); return $smarty->fetch('modules/mod-calendar_new.tpl'); } if (!empty($wiki)) { $tpl = "wiki:{$wiki}"; } elseif (!empty($tplwiki)) { $tpl = "tplwiki:{$tplwiki}"; } elseif (empty($tpl)) { $tpl = ''; } if (!empty($tpl)) { $smarty->security = true; } $smarty->assign('tpl', $tpl); if (!empty($itemId) && $showpagination == 'y' && !empty($_REQUEST['cant'])) { $smarty->assign('max', 1); $smarty->assign('count_item', $_REQUEST['cant']); $smarty->assign('offset_arg', 'reloff'); $smarty->assign("tr_offset{$iTRACKERLIST}", $_REQUEST['reloff']); } else { $smarty->assign_by_ref('max', $max); $smarty->assign_by_ref('item_count', $items['cant']); $smarty->assign_by_ref('count_item', $items['cant']); $smarty->assign('offset_arg', "tr_offset{$iTRACKERLIST}"); } $smarty->assign_by_ref('items', $items["data"]); $smarty->assign('daformat', $tikilib->get_long_date_format() . " " . tra("at") . " %H:%M"); if (!empty($params['showmap']) && $params['showmap'] == 'y') { $smarty->assign('trackerlistmapview', true); $smarty->assign('trackerlistmapname', "trackerlistmap_{$iTRACKERLIST}"); } else { $smarty->assign('trackerlistmapview', false); } if (isset($items['data'])) { foreach ($items['data'] as $score_item) { $item_info = $trklib->get_tracker_item($score_item['itemId']); $currentItemId = $score_item['itemId']; TikiLib::events()->trigger('tiki.trackeritem.view', array('type' => 'trackeritem', 'object' => $currentItemId, 'owner' => $item_info['createdBy'], 'user' => $GLOBALS['user'])); } } $tracker = $trklib->get_tracker($trackerId, 0, -1); /*foreach ($query_array as $k=>$v) { if (!is_array($v)) { //only to avoid an error: eliminate the params that are not simple (ex: if you have in the same page a tracker list plugin and a tracker plugin, filling the tracker plugin interfers with the tracker list. In any case this is buggy if two tracker list plugins in the same page and if one needs the query value.... $quarray[] = urlencode($k) ."=". urlencode($v); } } if (is_array($quarray)) { $query_string = implode("&",$quarray); } else { $quering_string = ''; } $smarty->assign('query_string', $query_string); */ if (!$tracker) { $smarty->assign('msg', tra("Error in tracker ID")); return $smarty->fetch("error_raw.tpl"); } else { $save_fc = null; if (!empty($wiki) && $params['force_compile'] === 'y') { // some pretty trackers need to compile fresh for each item $save_fc = $smarty->force_compile; $smarty->force_compile = true; } //this options preloads the javascript for displaying sheets if (!empty($displaysheet) && $displaysheet == 'y') { $headerlib = TikiLib::lib("header"); $sheetlib = TikiLib::lib("sheet"); $sheetlib->setup_jquery_sheet(); $headerlib->add_jq_onready('$("div.trackercontainer").sheet($.extend($.sheet.tikiOptions,{ editable:false, buildSheet: true, minSize: {rows: 0, cols: 0} }));'); $smarty->assign('displaysheet', 'true'); } //this method sets up the sheet just like it would for jquery.sheet, but assumes that the javascript will be handled elsewere if (!empty($tableassheet) && $tableassheet == 'y') { $smarty->assign('tableassheet', 'true'); } $smarty->assign('context', $params); try { $str = $smarty->fetch('wiki-plugins/wikiplugin_trackerlist.tpl'); } catch (SmartyException $e) { $str = $e->getMessage(); } if ($save_fc !== null) { $smarty->force_compile = $save_fc; // presumably will be false but put it back anyway } return $str; } } else { $smarty->assign('msg', tra("No field indicated")); return $smarty->fetch("error_raw.tpl"); } } return $back; }
function wikiplugin_fancytable($data, $params) { global $prefs; $tagremove = array(); $pluginremove = array(); static $iFancytable = 0; ++$iFancytable; extract($params, EXTR_SKIP); if (empty($sortable)) { $sortable = 'n'; } $msg = ''; if (isset($sortable) && $sortable != 'n') { $ts = new Table_Plugin(); if ($ts->perms !== false) { $ts->setSettings('fancytable_' . $iFancytable, 'n', $sortable, isset($sortList) ? $sortList : null, isset($tsortcolumns) ? $tsortcolumns : null, isset($tsfilters) ? $tsfilters : null, isset($tsfilteroptions) ? $tsfilteroptions : null, isset($tspaginate) ? $tspaginate : null); } else { $sort = false; } if (is_array($ts->settings)) { Table_Factory::build('plugin', $ts->settings); $sort = true; } else { $sort = false; } if ($sort === false) { if ($prefs['feature_jquery_tablesorter'] === 'n') { $msg = '<em>' . tra('The jQuery Sortable Tables feature must be activated for the sort feature to work.') . '</em>'; } elseif ($prefs['disableJavascript'] === 'y') { $msg = '<em>' . tra('Javascript must be enabled for the sort feature to work.') . '</em>'; } else { $msg = '<em>' . tra('Unable to load the jQuery Sortable Tables feature.') . '</em>'; } } } else { $sort = false; } //Start the table $style = $sort === true ? ' style="visibility:hidden"' : ''; $wret = '<div id="fancytable_' . $iFancytable . '"' . $style . '>' . "\r\t"; $wret .= '<table class="normal" id="fancytable_' . $iFancytable . '_table">' . "\r\t"; //Header if (isset($head)) { //set header class if (!empty($headclass)) { $tdhdr = "\r\t\t\t" . '<th class="' . $headclass . '"'; } else { $tdhdr = "\r\t\t\t<th"; } //replace tiki tags, plugins and other enclosing characters with hash strings before creating table so that any //pipes (| or ~|~) inside aren't mistaken for cell dividers preprocess_section($head, $tagremove, $pluginremove); if ($sort) { $type = 'hs'; } else { $type = 'h'; } //now create header table rows $headrows = process_section($head, $type, '>>', $tdhdr, '</th>', isset($colwidths) ? $colwidths : '', isset($headaligns) ? $headaligns : '', isset($headvaligns) ? $headvaligns : ''); //restore original tags and plugin syntax postprocess_section($headrows, $tagremove, $pluginremove); $wret .= '<thead>' . $headrows . "\r\t" . '</thead>' . "\r\t" . '<tbody>'; } //Body //replace tiki tags, plugins and other enclosing characters with hash strings before creating table so that any //pipes (| or ~|~) inside aren't mistaken for cell dividers preprocess_section($data, $tagremove, $pluginremove); if ($sort) { $type = 'bs'; //sortable body rows - do not assign odd/even class to these since jquery will do it } else { $type = 'b'; //plain body rows } //now create table body rows $bodyrows = process_section($data, $type, "\n", "\r\t\t\t" . '<td', '</td>', isset($colwidths) ? $colwidths : '', isset($colaligns) ? $colaligns : '', isset($colvaligns) ? $colvaligns : ''); //restore original tags and plugin syntax postprocess_section($bodyrows, $tagremove, $pluginremove); $wret .= $bodyrows; //end the table if (isset($head)) { $wret .= "\r\t" . '</tbody>'; } $wret .= "\r" . '</table></div>' . "\r" . $msg; return $wret; }
private function handleTablesorter($match) { $args = $this->parser->parse($match->getArguments()); if (!$this->tsOn) { return false; } if (!Table_Check::isAjaxCall()) { $ts = new Table_Plugin(); $ts->setSettings($this->id, isset($args['server']) ? $args['server'] : 'n', isset($args['sortable']) ? $args['sortable'] : 'y', isset($args['sortList']) ? $args['sortList'] : null, isset($args['tsortcolumns']) ? $args['tsortcolumns'] : null, isset($args['tsfilters']) ? $args['tsfilters'] : null, isset($args['tsfilteroptions']) ? $args['tsfilteroptions'] : null, isset($args['tspaginate']) ? $args['tspaginate'] : null, isset($args['tscolselect']) ? $args['tscolselect'] : null, $GLOBALS['requestUri'], $this->count, isset($args['tstotals']) ? $args['tstotals'] : null, isset($args['tstotalformat']) ? $args['tstotalformat'] : null, isset($args['tstotaloptions']) ? $args['tstotaloptions'] : null); if (is_array($ts->settings)) { $ts->settings['ajax']['offset'] = 'offset'; Table_Factory::build('PluginWithAjax', $ts->settings); $this->setTsSettings($ts->settings); } } }
$smarty->assign_by_ref('sort_mode', $sort_mode); $channels = $commentslib->list_forums($offset, $maxRecords, $sort_mode, $find); Perms::bulk(array('type' => 'forum'), 'object', $channels['data'], 'forumId'); //add tablesorter sorting and filtering $tsOn = Table_Check::isEnabled(true); $smarty->assign('tsOn', $tsOn); $tsAjax = Table_Check::isAjaxCall(); $smarty->assign('tsAjax', $tsAjax); static $iid = 0; ++$iid; $ts_tableid = 'forums' . $iid; $smarty->assign('ts_tableid', $ts_tableid); //initialize tablesorter if ($tsOn && !$tsAjax) { //set tablesorter code Table_Factory::build('TikiForums', array('id' => $ts_tableid, 'total' => $channels["cant"])); unset($channels); } else { $temp_max = count($channels["data"]); for ($i = 0; $i < $temp_max; $i++) { $forumperms = Perms::get(array('type' => 'forum', 'object' => $channels['data'][$i]['forumId'])); $channels["data"][$i]["individual_tiki_p_forum_read"] = $forumperms->forum_read ? 'y' : 'n'; $channels["data"][$i]["individual_tiki_p_forum_post"] = $forumperms->forum_post ? 'y' : 'n'; $channels["data"][$i]["individual_tiki_p_forum_post_topic"] = $forumperms->forum_post_topic ? 'y' : 'n'; $channels["data"][$i]["individual_tiki_p_forum_vote"] = $forumperms->forum_vote ? 'y' : 'n'; $channels["data"][$i]["individual_tiki_p_admin_forum"] = $forumperms->admin_forum ? 'y' : 'n'; } $smarty->assign_by_ref('channels', $channels["data"]); $smarty->assign('cant', $channels["cant"]); include_once 'tiki-section_options.php'; }
$type_param = ''; } else { $type_param = $_REQUEST['filter_type']; } if (!isset($_REQUEST['reply_state'])) { $reply_state = ''; } else { $reply_state = $_REQUEST['reply_state']; } //need the info on all threads so leave this even on initial non-ajax load $comments_coms = $commentslib->get_forum_topics($_REQUEST['forumId'], $comments_offset, $_REQUEST['comments_per_page'], $_REQUEST['thread_sort_mode'], $view_archived_topics, $user_param, $type_param, $reply_state, $forum_info); $comments_cant = $commentslib->count_forum_topics($_REQUEST['forumId'], $comments_offset, $_REQUEST['comments_per_page'], $_REQUEST['thread_sort_mode'], $view_archived_topics, $user_param, $type_param, $reply_state); //initialize tablesorter if ($tsOn && !$tsAjax) { //set tablesorter code Table_Factory::build('TikiViewforum', array('id' => $ts_tableid, 'total' => $comments_cant, 'pager' => array('max' => $_REQUEST['comments_per_page']), 'ajax' => array('requiredparams' => array('forumId' => $_REQUEST['forumId'])))); } $last_comments = $commentslib->get_last_forum_posts($_REQUEST['forumId'], $forum_info['forum_last_n']); $smarty->assign_by_ref('last_comments', $last_comments); $smarty->assign('comments_cant', $comments_cant); $comments_maxRecords = $_REQUEST["comments_per_page"]; $smarty->assign_by_ref('comments_coms', $comments_coms); $cat_type = 'forum'; $cat_objid = $_REQUEST["forumId"]; include_once 'tiki-section_options.php'; if ($prefs['feature_user_watches'] == 'y') { if ($user && isset($_REQUEST['watch_event'])) { check_ticket('view-forum'); if ($_REQUEST['watch_action'] == 'add') { $tikilib->add_user_watch($user, $_REQUEST['watch_event'], $_REQUEST['watch_object'], 'forum', $forum_info['name'], 'tiki-view_forum.php?forumId=' . $_REQUEST['forumId']); } else {
/** * Uses table settings to generate necessary jQuery and HTML code * * @param $settings settings created by running the appropriate Table_Settings class */ private function setAllCode($settings) { $this->codeObj = Table_Factory::build('manager', $settings, 'code'); $this->codeObj->setCode(); }
$channels["data"][$i]["individual"] = 'n'; } } //add tablesorter sorting and filtering $tsOn = Table_Check::isEnabled(true); $smarty->assign('tsOn', $tsOn); $tsAjax = Table_Check::isAjaxCall(); $smarty->assign('tsAjax', $tsAjax); static $iid = 0; ++$iid; $ts_tableid = 'adminforums' . $iid; $smarty->assign('ts_tableid', $ts_tableid); //initialize tablesorter if ($tsOn && !$tsAjax) { //set tablesorter code Table_Factory::build('TikiAdminForums', array('id' => $ts_tableid, 'total' => $channels['cant'])); } $smarty->assign_by_ref('channels', $channels["data"]); $smarty->assign_by_ref('cant', $channels["cant"]); $cat_type = 'forum'; $cat_objid = $_REQUEST["forumId"]; $categories = array(); include_once "categorize_list.php"; if (!empty($_REQUEST['dup_mode'])) { if ($offset == 0 && ($maxRecords == -1 || $channels['cant'] <= $maxRecords)) { $smarty->assign_by_ref('allForums', $channels['data']); } else { $allForums = $commentslib->list_forums(0, -1, 'name_asc'); $smarty->assign_by_ref('allForums', $allForums['data']); } $smarty->assign_by_ref('dup_mode', $_REQUEST['dup_mode']);
static $iid = 0; ++$iid; $ts_tableid = 'adminusers' . $iid; $smarty->assign('ts_tableid', $ts_tableid); if (!$tsOn || $tsOn && $tsAjax) { $users = $userlib->get_users($offset, $numrows, $sort_mode, $find, $initial, true, $filterGroup, $filterEmail, !empty($_REQUEST['filterEmailNotConfirmed']), !empty($_REQUEST['filterNotValidated']), !empty($_REQUEST['filterNeverLoggedIn'])); } if ($tsOn && !$tsAjax) { $users['cant'] = $userlib->count_users(''); $users['data'] = $users['cant'] > 0 ? true : false; //delete anonymous out of group list used for dropdown $ts_groups = array_flip($all_groups); unset($ts_groups['Anonymous']); $ts_groups = array_flip($ts_groups); //set tablesorter code Table_Factory::build('TikiAdminusers', array('id' => $ts_tableid, 'total' => $users['cant'], 'columns' => array('#groups' => array('filter' => array('options' => $ts_groups))))); } $smarty->assign_by_ref('users', $users['data']); $smarty->assign_by_ref('cant', $users['cant']); if (isset($_REQUEST['add'])) { $cookietab = '2'; } if (count($errors) > 0) { exit_with_error_messages($errors); } if (isset($_POST['ajaxtype'])) { $smarty->assign('ajaxfeedback', 'y'); $ajaxpost = array_intersect_key($_POST, ['ajaxtype' => '', 'ajaxheading' => '', 'ajaxitems' => '', 'ajaxmsg' => '', 'ajaxtoMsg' => '', 'ajaxtoList' => '']); $smarty->assign($ajaxpost); } $smarty->assign_by_ref('all_groups', $all_groups);
$ts_offsetid = 'usertable-offset'; $smarty->assign('ts_countid', $ts_countid); $smarty->assign('ts_offsetid', $ts_offsetid); } if (!$tsOn || $tsOn && $tsAjax) { $users = $userlib->get_users($offset, $numrows, $sort_mode, $find, $initial, true, $filterGroup, $filterEmail, !empty($_REQUEST['filterEmailNotConfirmed']), !empty($_REQUEST['filterNotValidated']), !empty($_REQUEST['filterNeverLoggedIn'])); } if ($tsOn && !$tsAjax) { $users['cant'] = $userlib->count_users(''); $users['data'] = $users['cant'] > 0 ? true : false; //delete anonymous out of group list used for dropdown $ts_groups = array_flip($all_groups); unset($ts_groups['Anonymous']); $ts_groups = array_flip($ts_groups); //set tablesorter code Table_Factory::build('adminusers', array('total' => $users['cant'], 'filters' => array('columns' => array(6 => array('options' => $ts_groups))), 'ajax' => array('servercount' => array('id' => $ts_countid), 'serveroffset' => array('id' => $ts_offsetid)))); } $smarty->assign_by_ref('users', $users['data']); $smarty->assign_by_ref('cant', $users['cant']); if (isset($_REQUEST['add'])) { $cookietab = '2'; } if (count($errors) > 0) { exit_with_error_messages($errors); } $smarty->assign_by_ref('all_groups', $all_groups); $smarty->assign('userinfo', $userinfo); $smarty->assign('userId', $_REQUEST['user']); $smarty->assign('username', $username); $smarty->assign('usermail', $usermail); $smarty->assign_by_ref('tikifeedback', $tikifeedback);
if (strpos($sort_mode, '_desc') !== false) { $pos = strlen($sort_mode) - 5; $sortdir = 1; } elseif (strpos($sort_mode, '_asc') !== false) { $pos = strlen($sort_mode) - 4; $sortdir = 0; } ///set sort column $sort = substr($sort_mode, 0, $pos); $sortcol = array_search($sort, $cols); $settings = array('id' => $ts_tableid, 'total' => $listpages['cant'], 'vars' => array('show_actions' => $show_actions), 'columns' => array('#language' => array('filter' => array('options' => $ts_langs)), '#categories' => array('filter' => array('options' => $cnames)), '#catpaths' => array('filter' => array('options' => $cpaths)))); if ($sortcol !== false) { $settings['sorts']['sortlist']['col'] = $sortcol; $settings['sorts']['sortlist']['dir'] = $sortdir; } Table_Factory::build('TikiListpages', $settings); } if ($access->is_serializable_request()) { if (isset($_REQUEST['listonly']) && ($prefs['feature_jquery'] == 'y' && $prefs['feature_jquery_autocomplete'] == 'y')) { $pages = array(); foreach ($listpages['data'] as $page) { if (isset($_REQUEST['nonamespace'])) { $pages[] = TikiLib::lib('wiki')->get_without_namespace($page['pageName']); } else { $pages[] = $page['pageName']; } } $access->output_serialized($pages); } else { $pages = array(); $wikilib = TikiLib::lib('wiki');