/** * display block * * @param array $blockinfo a blockinfo structure * @return output the rendered bock */ public function display($blockinfo) { // Security check if (!SecurityUtil::checkPermission('EZComments:EZCommentsblock:', "{$blockinfo['bid']}::", ACCESS_READ)) { return false; } if (!ModUtil::load('EZComments')) { return false; } // Get variables from content block $vars = BlockUtil::varsFromContent($blockinfo['content']); // Defaults if (!isset($vars['numentries'])) { $vars['numentries'] = 5; } if (!isset($vars['numdays'])) { $vars['numdays'] = 0; } if (!isset($vars['showdate'])) { $vars['showdate'] = 0; } if (!isset($vars['showusername'])) { $vars['showusername'] = 0; } if (!isset($vars['linkusername'])) { $vars['linkusername'] = 0; } $options = array('numitems' => $vars['numentries']); if (isset($vars['mod']) && $vars['mod'] != '*') { $options['mod'] = $vars['mod']; } if (!isset($vars['showpending']) || $vars['showpending'] == 0) { // don't show pending comments $options['status'] = 0; } // filter comments posted in last number of days if ($vars['numdays'] > 0) { // date for filtering in format: yyyy-mm-dd hh:mm:ss $options['addwhere'] = "date>='" . DateUtil::getDatetime_NextDay(-$vars['numdays']) . "'"; } // get the comments $items = ModUtil::apiFunc('EZComments', 'user', 'getall', $options); // augment the info $comments = ModUtil::apiFunc('EZComments', 'user', 'prepareCommentsForDisplay', $items); $this->view->assign($vars); $this->view->assign('comments', $comments); // Populate block info and pass to theme $blockinfo['content'] = $this->view->fetch('ezcomments_block_ezcomments.tpl'); return BlockUtil::themesideblock($blockinfo); }
/** * Display the data to the containing Content page */ public function display() { // Parameters for category related items properties like topicimage $lang = ZLanguage::getLanguageCode(); $topicProperty = ModUtil::getVar('News', 'topicproperty'); $topicField = empty($topicProperty) ? 'Main' : $topicProperty; // work out the parameters for the News api call $apiargs = array(); switch ($this->show) { case 3: // non index page articles $apiargs['displayonindex'] = 0; break; case 2: // index page articles $apiargs['displayonindex'] = 1; break; // all - doesn't need displayonindex } $apiargs['numitems'] = $this->limit; // Nr of articles to obtain $apiargs['status'] = (int) $this->status; // Published status // Handle the sorting order switch ($this->orderoptions) { case 2: $apiargs['order'] = 'weight'; break; case 3: $apiargs['order'] = 'random'; break; case 1: $apiargs['order'] = 'counter'; break; case 0: default: // Use News module setting, so don't set apiargs[order] } $enablecategorization = ModUtil::getVar('News', 'enablecategorization'); // Make a category filter only if categorization is enabled in News module if ($enablecategorization && $this->categories != null) { // Get the registrered categories for the News module $catregistry = CategoryRegistryUtil::getRegisteredModuleCategories('News', 'news'); $apiargs['catregistry'] = $catregistry; $apiargs['category'] = $this->categories; } // Limit the shown articles in days using DateUtil if ((int) $this->dayslimit > 0 && $vars['order'] == 0) { $apiargs['from'] = DateUtil::getDatetime_NextDay(-$this->dayslimit); $apiargs['to'] = DateUtil::getDatetime(); } // Apply datefiltering $apiargs['filterbydate'] = true; // call the News api and get the requested articles with the above arguments $items = ModUtil::apiFunc('News', 'user', 'getall', $apiargs); // UserUtil is not automatically loaded, so load it now if needed and set anonymous if ($this->dispuname) { $anonymous = System::getVar('anonymous'); } // check for an empty return if (!empty($items)) { // loop through the items and prepare for display foreach (array_keys($items) as $k) { // Get specific information from the article. It was a choice not to use the pnuserapi functions // GetArticleInfo, GetArticleLinks and getArticlesPreformat because of speed etc. // --- Check for Topic related properties like topicimage, topicsearchurl etc. if ($enablecategorization && !empty($items[$k]['__CATEGORIES__']) && isset($items[$k]['__CATEGORIES__'][$topicField])) { $items[$k]['topicid'] = $items[$k]['__CATEGORIES__'][$topicField]['id']; $items[$k]['topicname'] = isset($items[$k]['__CATEGORIES__'][$topicField]['display_name'][$lang]) ? $items[$k]['__CATEGORIES__'][$topicField]['display_name'][$lang] : $items[$k]['__CATEGORIES__'][$topicField]['name']; // set the topic image if topic_image category property exists $items[$k]['topicimage'] = (isset($items[$k]['__CATEGORIES__'][$topicField]['__ATTRIBUTES__']) && isset($items[$k]['__CATEGORIES__'][$topicField]['__ATTRIBUTES__']['topic_image'])) ? $items[$k]['__CATEGORIES__'][$topicField]['__ATTRIBUTES__']['topic_image'] : ''; // set the topic description if exists $items[$k]['topictext'] = isset($items[$k]['__CATEGORIES__'][$topicField]['display_desc'][$lang]) ? $items[$k]['__CATEGORIES__'][$topicField]['display_desc'][$lang] : ''; // set the path of the topic $items[$k]['topicpath'] = isset($items[$k]['__CATEGORIES__'][$topicField]['path_relative']) ? $items[$k]['__CATEGORIES__'][$topicField]['path_relative'] : ''; // set the url to search for this topic if (System::getVar('shorturls', false)) { $items[$k]['topicsearchurl'] = DataUtil::formatForDisplay(ModUtil::url('News', 'user', 'view', array('prop' => $topicField, 'cat' => $items[$k]['topicpath']))); } else { $items[$k]['topicsearchurl'] = DataUtil::formatForDisplay(ModUtil::url('News', 'user', 'view', array('prop' => $topicField, 'cat' => $items[$k]['topicid']))); } } else { $items[$k]['topicid'] = null; $items[$k]['topicname'] = ''; $items[$k]['topicimage'] = ''; $items[$k]['topictext'] = ''; $items[$k]['topicpath'] = ''; $items[$k]['topicsearchurl'] = ''; } // Optional new image if the difference in days from the publishing date and now < the specified limit $items[$k]['dispnewimage'] = ($this->dispnewimage && DateUtil::getDatetimeDiff_AsField($items[$k]['from'], DateUtil::getDatetime(), 3) < (int) $this->newimagelimit); // Wrap the title if needed $items[$k]['titlewrapped'] = false; if ((int) $this->maxtitlelength > 0 && strlen($items[$k]['title']) > (int) $this->maxtitlelength) { // wrap the title $items[$k]['title'] = substr($items[$k]['title'], 0, (int) $this->maxtitlelength); $items[$k]['titlewrapped'] = true; //$items[$k]['title'] .= $this->titlewraptext; } // Get the user information from the author id if ($this->dispuname) { if ($items[$k]['cr_uid'] == 0) { $items[$k]['uname'] = $anonymous; $items[$k]['aid_name'] = $anonymous; } else { $user = UserUtil::getVars($items[$k]['cr_uid']); $items[$k]['uname'] = $user['uname']; $items[$k]['aid_name'] = $user['uname']; } } // Get the optional commentcount if EZComments is available if ($this->dispcomments && ModUtil::available('EZComments')) { $items[$k]['comments'] = ModUtil::apiFunc('EZComments', 'user', 'countitems', array('mod' => 'News', 'objectid' => $items[$k]['sid'], 'status' => 0)); } // Optional display of the hometext (frontpage teaser) if ($this->disphometext) { if ($this->maxhometextlength > 0 && strlen(strip_tags($items[$k]['hometext'])) > (int) $this->maxhometextlength) { $items[$k]['hometextwrapped'] = true; } } $items[$k]['readperm'] = (SecurityUtil::checkPermission('News::', "$items[$k][cr_uid]::$items[$k][sid]", ACCESS_READ)); } if ($this->dispuname || $this->dispdate || $this->dispreads || $this->dispcomments) { $this->view->assign('dispinfo', true); $this->view->assign('dispuname', $this->dispuname); $this->view->assign('dispdate', $this->dispdate); $this->view->assign('dispreads', $this->dispreads); $this->view->assign('dispcomments', $this->dispcomments); $this->view->assign('dispsplitchar', $this->dispsplitchar); } else { $this->view->assign('dispinfo', false); } if ($this->dispnewimage) { $this->view->assign('newimageset', $this->newimageset); $this->view->assign('newimagesrc', $this->newimagesrc); } $this->view->assign('disphometext', $this->disphometext); if ($this->disphometext) { $this->view->assign('hometextwraptext', $this->hometextwraptext); $this->view->assign('maxhometextlength', $this->maxhometextlength); } $this->view->assign('titlewraptext', $this->titlewraptext); } $this->view->assign('News', ModUtil::getVar('News')); $this->view->assign('dateformat', $this->dateformat); $this->view->assign('linktosubmit', $this->linktosubmit); $this->view->assign('stories', $items); $this->view->assign('title', $this->title); $this->view->assign('displayStoryImage', $this->displayStoryImage); $this->view->assign('useshorturls', System::getVar('shorturls', false)); return $this->view->fetch($this->getTemplate()); }
/** * Get bookings depending on date periods * @author Albert Pérez Monfort (aperezm@xtec.cat) * @author Josep Ferràndiz Farré (jferran6@xtec.cat) * @return List or table with the bookings */ public function taula($args) { // Security check if (!SecurityUtil::checkPermission('IWbookings::', "::", ACCESS_READ)) { throw new Zikula_Exception_Forbidden(); } $sid = FormUtil::getPassedValue('sid', isset($args['sid']) ? $args['sid'] : null, 'GETPOST'); $mensual = FormUtil::getPassedValue('mensual', isset($args['mensual']) ? $args['mensual'] : null, 'GET'); $currentDate = FormUtil::getPassedValue('currentDate', isset($args['currentDate']) ? $args['currentDate'] : null, 'GET'); $canbook = FormUtil::getPassedValue('canbook', isset($args['canbook']) ? $args['canbook'] : false, 'GET'); //Array amb els noms dels dies de la setmana $dies = array($this->__('Monday'), $this->__('Tuesday'), $this->__('Wednesday'), $this->__('Thursday'), $this->__('Friday'), $this->__('Saturday'), $this->__('Sunday')); //D'entrada farem que les taules es mostrin de forma horitzontal. Despr�s, si //hi ha un marc horari definit canviarem al que correspongui $vertical = 0; //(ModUtil::getVar('IWbookings', 'eraseold')==1)? //$actualitza=ModUtil::apiFunc('IWbookings','user','esborra_antigues', array('sid'=> $sid, 'mensual'=> $mensual)):""; // Get space info $espai = ModUtil::apiFunc('IWbookings', 'user', 'get', array('sid' => $sid)); //Per si falla la c�rrega de les dades if ($espai == false) { return LogUtil::registerError($this->__('The room or equipment was not found')); } $nom_espai = $espai['space_name']; //Comprovem si la taula est� lligada a un marc horari i si aquest marc horari //no ha estat esborrat if ($espai['mdid'] != 0) { //Busquem les franges hor�ries $franges = ModUtil::apiFunc('IWbookings', 'user', 'getall_hores', array('mdid' => $espai['mdid'])); if (!empty($franges)) { $vertical = $espai['vertical']; } } // Obtenim la data inicial i final de la setmana seleccionada $week = ModUtil::apiFunc('IWbookings', 'user', 'getWeek', array('date' => $currentDate, 'format' => 'ymd')); $startDate = $week['start']; $endDate = $week['end']; //Generem la taula amb el format corresponent if ($vertical != 1) { //Taula en format horitzontal $taula = array(); $d = 0; $fields1 = explode('-', $startDate); $i = 0; foreach ($dies as $dia) { $i++; $today = DateUtil::getDatetime_NextDay(($i - 1), '%Y-%m-%d', $fields1[0], // Year $fields1[1], // Month $fields1[2]); // Day; $tomorrow = DateUtil::getDatetime_NextDay(($i), '%Y-%m-%d %H:%M:%S', $fields1[0], // Year $fields1[1], // Month $fields1[2], 23, 59, 59); // Day; $reserves = ModUtil::apiFunc('IWbookings', 'user', 'getall_reserves', array('sid' => $sid, 'from' => $today, 'to' => $tomorrow)); $registres = array(); //Afegim les reserves temporals a la matriu registres fent la correcci� de la data foreach ($reserves as $reserva) { //Mirem que coincideixi el dia de la setmana if ($reserva['dayofweek'] == $i) { if (($reserva['usuari'] == UserUtil::getVar('uid')) or (SecurityUtil::checkPermission('IWbookings::', "::", ACCESS_ADMIN))) { $candelete = true; } else { $candelete = false; } $registres[] = array('inici' => $reserva['inici'], 'final' => $reserva['final'], 'bid' => $reserva['bid'], 'usuari' => $reserva['usuari'], 'dow' => $dies[$i - 1], 'grup' => $reserva['grup'], 'motiu' => $reserva['motiu'], 'candelete' => $candelete, 'temp' => $reserva['temp']); } } if (!empty($registres)) { $nr = 0; foreach ($registres as $registre) { $registre['data'] = $registre['dow'] . " " . date('d-m-Y', strtotime($today)); //$dia." ".date("d/m/y",$data1); $registre['inici'] = date('H:i', strtotime($registre['inici'])); //date("H:i",$registre['inici']); $registre['final'] = date('H:i', strtotime($registre['final'])); //date("H:i",$registre['final']); $registre['usuari'] = ModUtil::func('IWmain', 'user', 'getUserInfo', array('uid' => $registre['usuari'], 'sv' => ModUtil::func('IWmain', 'user', 'genSecurityValue'), 'info' => 'ncc')); $taula[$d][$nr] = $registre; $nr++; //Incrementem l'�ndex de reserves del dia } $d++; //Incrementem el dia } } // foreach $dies $this->view->assign('numdies', count($taula)) ->assign('record', $taula); } else { // show bookings in table format $dies_data = array(); $fields = explode('-', $startDate); (ModUtil::getVar('IWbookings', 'weekends')) ? $numdies = 7 : $numdies = 5; for ($i = 0; $i <= $numdies; $i++) { $dies_data[$i] = DateUtil::buildDatetime($fields[0], $fields[1], $fields[2] + $i, 0, 0, 0, '%d-%m-%y'); // Day } //Make table column headers: day of week and date (ModUtil::getVar('IWbookings', 'weekends')) ? $dies_taula = array($this->__('Monday') . ' ' . $dies_data[0], $this->__('Tuesday') . ' ' . $dies_data[1], $this->__('Wednesday') . ' ' . $dies_data[2], $this->__('Thursday') . ' ' . $dies_data[3], $this->__('Friday') . ' ' . $dies_data[4], $this->__('Saturday') . ' ' . $dies_data[5], $this->__('Sunday') . ' ' . $dies_data[6]) : $dies_taula = array($this->__('Monday') . ' ' . $dies_data[0], $this->__('Tuesday') . ' ' . $dies_data[1], $this->__('Wednesday') . ' ' . $dies_data[2], $this->__('Thursday') . ' ' . $dies_data[3], $this->__('Friday') . ' ' . $dies_data[4]); // Get all bookings between startDate and endDate $reserves = ModUtil::apiFunc('IWbookings', 'user', 'getall_reserves', array('sid' => $sid, 'from' => $startDate, 'to' => $endDate)); $now = DateUtil::getDatetime(DateUtil::makeTimestamp() + SessionUtil::getVar('timeOffset')); //Generem les franges hor�ries amb les corresponents reserves //Generate timeframes with their bookings $i = 0; $f = 0; foreach ($franges as $franja) { $horari[$i]['hi'] = substr($franja['hora'], 0, 5); $horari[$i]['hf'] = substr($franja['hora'], -5); $temps = explode(":", substr($franja['hora'], -5)); $j = 0; $d = 0; foreach ($dies as $dia) { $j++; $registre1 = array(); foreach ($reserves as $reserva) { // Mirem que coincideixi el dia de la setmana // See day of week coincidence if ($reserva['dayofweek'] == $j && (date('H:i', strtotime($reserva['inici'])) == substr($franja['hora'], 0, 5)) && (date('H:i', strtotime($reserva['final'])) == substr($franja['hora'], -5))) { $usr = ModUtil::func('IWmain', 'user', 'getUserInfo', array('uid' => $reserva['usuari'], 'sv' => ModUtil::func('IWmain', 'user', 'genSecurityValue'), 'info' => 'ncc')); //if (($reserva['usuari'] == UserUtil::getVar('uid')) or (SecurityUtil::checkPermission('IWbookings::', "::", ACCESS_DELETE))) { if (($reserva['usuari'] == UserUtil::getVar('uid')) or (SecurityUtil::checkPermission('IWbookings::', "::", ACCESS_ADMIN))) { $candelete = true; } else { $candelete = false; } $registre1 = array('inici' => $reserva['inici'], 'final' => $reserva['final'], 'bid' => $reserva['bid'], 'grup' => $reserva['grup'], 'motiu' => $reserva['motiu'], 'temp' => $reserva['temp'], 'candelete' => $candelete, 'usuari' => $usr); } } $taula[$f][$d] = $registre1; if (empty($registre1)) { $taula[$f][$d]['usuari'] = " - "; // Data i hora de refer�ncia per comparar amb la actual i decidir si es mostra o no // Assign a date and a time. This value is compared with real time and date and determines if it will be showed or not $taula[$f][$d]['final'] = DateUtil::buildDatetime($fields[0], $fields[1], $fields[2] + ($d), $temps[0], $temps[1], 0, '%Y-%m-%d %H:%M:%S'); } // Incrementem el dia de la setmana // Increase the day of week $d++; } // Passem a la seg�ent franja hor�ria // Next timeframe $f++; $i++; } $this->view->assign('dies_data', $dies_data) ->assign('dies_taula', $dies_taula) ->assign('franges', $franges) ->assign('horari', $horari) ->assign('record', $taula) ->assign('now', $now); } $this->view->assign('vertical', $vertical) ->assign('canbook', $canbook) ->assign('sid', $sid) ->assign('dies', $dies) ->assign('date', date('Y-m-d', strtotime($currentDate))) ->assign('d', date('d-m-y', strtotime($currentDate))) ->assign('periode', $this->__('Period from ') . date('d-m-Y', strtotime($startDate)) . $this->__(' to ') . date('d-m-Y', strtotime($endDate))); return $this->view->fetch('IWbookings_user_taula.htm'); }
/** * display block * * @author Erik Spaan [espaan] * @param array $blockinfo a blockinfo structure * @return output the rendered bock */ public function display($blockinfo) { if (!SecurityUtil::checkPermission('Storiesextblock::', "$blockinfo[bid]::", ACCESS_OVERVIEW)) { return; } // Break out options from our content field $vars = BlockUtil::varsFromContent($blockinfo['content']); // Get the News categorization setting $enablecategorization = ModUtil::getVar('News', 'enablecategorization'); $lang = ZLanguage::getLanguageCode(); $topicProperty = ModUtil::getVar('News', 'topicproperty'); $topicField = empty($topicProperty) ? 'Main' : $topicProperty; $catimagepath = ModUtil::getVar('News', 'catimagepath'); // --- Setting of the Defaults if (!isset($vars['category'])) { $vars['category'] = null; } if (!isset($vars['show'])) { $vars['show'] = 1; } if (!isset($vars['status'])) { $vars['status'] = 0; } if (!isset($vars['order'])) { $vars['order'] = 0; } if (!isset($vars['limit'])) { $vars['limit'] = 5; } // Maximum article age in days if (!isset($vars['dayslimit'])) { $vars['dayslimit'] = 0; } // Maximum title length if (!isset($vars['maxtitlelength'])) { $vars['maxtitlelength'] = 0; } if (!isset($vars['titlewraptxt'])) { $vars['titlewraptxt'] = '...'; } // Show 'No News' message instead of empty block if (!isset($vars['showemptyresult'])) { $vars['showemptyresult'] = 0; } // Override templates for the block and row display if (!isset($vars['blocktemplate'])) { $vars['blocktemplate'] = ''; } if (!isset($vars['rowtemplate'])) { $vars['rowtemplate'] = ''; } // Display optional article information $vars['dispuname'] = (!isset($vars['dispuname'])) ? false : !empty($vars['dispuname']); $vars['dispdate'] = (!isset($vars['dispdate'])) ? true : !empty($vars['dispdate']); if (!isset($vars['dateformat'])) { $vars['dateformat'] = '%x'; } $vars['dispreads'] = (!isset($vars['dispreads'])) ? false : !empty($vars['dispreads']); $vars['dispcomments'] = (!isset($vars['dispcomments'])) ? false : !empty($vars['dispcomments']); if (!isset($vars['dispsplitchar'])) { $vars['dispsplitchar'] = ', '; } // Display (part of) the hometext of the article $vars['disphometext'] = (!isset($vars['disphometext'])) ? false : !empty($vars['disphometext']); if (!isset($vars['maxhometextlength'])) { $vars['maxhometextlength'] = 0; } if (!isset($vars['hometextwraptxt'])) { $vars['hometextwraptxt'] = '...'; } // Display of a new story image $vars['dispnewimage'] = (!isset($vars['dispnewimage'])) ? false : !empty($vars['dispnewimage']); if (!isset($vars['newimagelimit'])) { $vars['newimagelimit'] = 3; } if (!isset($vars['newimageset'])) { $vars['newimageset'] = 'icons/extrasmall/'; } if (!isset($vars['newimagesrc'])) { $vars['newimagesrc'] = 'favorites.png'; } // display the items in a scrolling box, pausing, fading or marquee if (!isset($vars['scrolling'])) { $vars['scrolling'] = 1; } if (!isset($vars['scrollstyle'])) { $vars['scrollstyle'] = '%DIVID% { width:inherit; overflow:hidden; position:relative; padding:2px; border:0px solid black; background:transparent; /* IE: Height + 2*padding + 2*border */ height:54px; voice-family: "\"}\""; voice-family:inherit; /* regular height */ height:50px; } /* Opera browser */ html>body %DIVID% { height:50px; }'; } if (!isset($vars['scrolldelay'])) { $vars['scrolldelay'] = 3000; } if (!isset($vars['scrollmspeed'])) { $vars['scrollmspeed'] = 2; } $scrollfilterduration = 1.0; // --- Work out the parameters for the News api call, fill the apiargs array with the necessary fields $apiargs = array(); switch ($vars['show']) { case 3: // non index page articles $apiargs['displayonindex'] = 0; break; case 2: // index page articles $apiargs['displayonindex'] = 1; break; // all - doesn't need displayonindex } $apiargs['numitems'] = $vars['limit']; // Nr of articles to obtain $apiargs['status'] = $vars['status']; // Published status // Make a category filter only if categorization is enabled in News module if ($enablecategorization) { // Get the registrered categories for the News module $catregistry = CategoryRegistryUtil::getRegisteredModuleCategories('News', 'news'); $apiargs['catregistry'] = $catregistry; $apiargs['category'] = $vars['category']; } // Limit the shown articles in days using DateUtil if ((int)$vars['dayslimit'] > 0 && $vars['order'] == 0) { $apiargs['from'] = DateUtil::getDatetime_NextDay(-$vars['dayslimit']); $apiargs['to'] = DateUtil::getDatetime(); } // Handle the sorting order switch ($vars['order']) { case 2: $apiargs['order'] = 'weight'; break; case 3: $apiargs['order'] = 'random'; break; case 1: $apiargs['order'] = 'counter'; break; case 0: default: // Use News module setting, so don't set apiargs[order] } // Make sure datefiltering is done. Solves #12 $apiargs['filterbydate'] = true; // Call the News api and get the requested articles with the above arguments $items = ModUtil::apiFunc('News', 'user', 'getall', $apiargs); // check for an empty return if (empty($items)) { if ($vars['showemptyresult']) { // Show empty result message instead of empty block if variable is set $blockinfo['content'] = $this->__('No articles.'); return BlockUtil::themeBlock($blockinfo); } else { return; } } // UserUtil is not automatically loaded, so load it now if needed and set anonymous if ($vars['dispuname']) { $anonymous = System::getVar('anonymous'); } // --- Select the configurable row template or the default. The row templates is cached with its sid (storyid) $storiesoutput = array(); if (!empty($vars['rowtemplate'])) { $rowtemplate = $vars['rowtemplate']; } else { $rowtemplate = 'block/storiesext/row.tpl'; } // --- loop through the items and prepare every News item for display foreach ($items as $item) { // Get specific information from the article. It was a choice not to use the pnuserapi functions // GetArticleInfo, GetArticleLinks and getArticlesPreformat because of speed etc. // --- Check for Topic related properties like topicimage, topicsearchurl etc. if ($enablecategorization && !empty($item['__CATEGORIES__']) && isset($item['__CATEGORIES__'][$topicField])) { $item['topicid'] = $item['__CATEGORIES__'][$topicField]['id']; $item['topicname'] = isset($item['__CATEGORIES__'][$topicField]['display_name'][$lang]) ? $item['__CATEGORIES__'][$topicField]['display_name'][$lang] : $item['__CATEGORIES__'][$topicField]['name']; // set the topic image if topic_image category property exists $item['topicimage'] = (isset($item['__CATEGORIES__'][$topicField]['__ATTRIBUTES__']) && isset($item['__CATEGORIES__'][$topicField]['__ATTRIBUTES__']['topic_image'])) ? $item['__CATEGORIES__'][$topicField]['__ATTRIBUTES__']['topic_image'] : ''; // set the topic description if exists $item['topictext'] = isset($item['__CATEGORIES__'][$topicField]['display_desc'][$lang]) ? $item['__CATEGORIES__'][$topicField]['display_desc'][$lang] : ''; // set the path of the topic $item['topicpath'] = $item['__CATEGORIES__'][$topicField]['path_relative']; // set the url to search for this topic if (System::getVar('shorturls', false)) { $item['topicsearchurl'] = DataUtil::formatForDisplay(ModUtil::url('News', 'user', 'view', array('prop' => $topicField, 'cat' => $item['topicpath']))); } else { $item['topicsearchurl'] = DataUtil::formatForDisplay(ModUtil::url('News', 'user', 'view', array('prop' => $topicField, 'cat' => $item['topicid']))); } } else { $item['topicid'] = null; $item['topicname'] = ''; $item['topicimage'] = ''; $item['topictext'] = ''; $item['topicpath'] = ''; $item['topicsearchurl'] = ''; } // Optional new image if the difference in days from the publishing date and now < the limit $item['itemnewimage'] = ($vars['dispnewimage'] && DateUtil::getDatetimeDiff_AsField($item['from'], DateUtil::getDatetime(), 3) < (int)$vars['newimagelimit']); // Wrap the title if needed $item['titlewrapped'] = false; if ($vars['maxtitlelength'] > 0 && strlen($item['title']) > (int)$vars['maxtitlelength']) { // wrap the title with wordwrap (instead of substr) $a = explode('[[[wrap]]]', wordwrap($item['title'], (int)$vars['maxtitlelength'], '[[[wrap]]]')); $item['title'] = $a[0]; $item['titlewrapped'] = true; } if ($vars['dispuname']) { // Get the user information from the author id if ($item['cr_uid'] == 0) { $this->view->assign('uname', $anonymous); $this->view->assign('aid_name', $anonymous); } else { $user = UserUtil::getVars($item['cr_uid']); $this->view->assign('uname', $user['uname']); $this->view->assign('aid_name', $user['name']); } } // Check for EZComments if ($vars['dispcomments'] && ModUtil::available('EZComments')) { $item['comments'] = ModUtil::apiFunc('EZComments', 'user', 'countitems', array('mod' => 'News', 'objectid' => $item['sid'], 'status' => 0)); } if ($vars['disphometext']) { if ($vars['maxhometextlength'] > 0 && strlen(strip_tags($item['hometext'])) > (int)$vars['maxhometextlength']) { $item['hometextwrapped'] = true; } } if ($vars['dispuname']||$vars['dispdate']||$vars['dispreads']||$vars['dispcomments']) { $this->view->assign('dispinfo', true); } $this->view->assign('readperm',(bool)SecurityUtil::checkPermission('News::', "$item[cr_uid]::$item[sid]", ACCESS_READ)); $this->view->assign($vars); $this->view->assign($item); // Get the cached output per row $storiesoutput[] = $this->view->fetch($rowtemplate, $item['sid']); } // Turn of caching for the block display $this->view->setCaching(false); // Use the configured template if set, otherwise use the default static/scrolling ones. if (!empty($vars['blocktemplate'])) { $blocktemplate = $vars['blocktemplate']; } else { $blocktemplate = 'block/storiesext/main.tpl'; if ((int)$vars['scrolling']>1) { switch ((int)$vars['scrolling']) { case 2: $blocktemplate = 'block/storiesext/scrollpause.tpl'; break; case 3: $blocktemplate = 'block/storiesext/scrollfade.tpl'; // Add the IE fading effect to the existing scrollstyle $vars['scrollstyle'] .= '%DIVID% {filter: progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=1.0 Duration=' . $scrollfilterduration . ')}'; break; case 4: $blocktemplate = 'block/storiesext/scrollmarquee.tpl'; $this->view->assign('scrollmspeed', $vars['scrollmspeed']); break; } $this->view->assign('scrollstyle', $vars['scrollstyle']); $this->view->assign('scrolldelay', $vars['scrolldelay']); } } $this->view->assign('catimagepath', $catimagepath); $this->view->assign('bid', $blockinfo['bid']); $this->view->assign('stories', $storiesoutput); $blockinfo['content'] = $this->view->fetch($blocktemplate); return BlockUtil::themeBlock($blockinfo); }
/** * Calcula la data inicial de la setmana a la qual pertany una determinada data * @author Josep Ferr�ndiz Farr� (jferran6@xtec.cat) * @args The date (a MySQL timestamp or a string) * @return the start date of the week */ public function getWeek($args) { $TheDate = FormUtil::getPassedValue('date', isset($args['date']) ? $args['date'] : null, 'GET'); $format = FormUtil::getPassedValue('format', isset($args['format']) ? $args['format'] : null, 'GET'); $week = array(); if (!SecurityUtil::checkPermission('IWbookings::', '::', ACCESS_READ)) { return $week; } $avui = DateUtil::makeTimestamp($TheDate); $dow = date("w", $avui); ($dow == 0) ? $dow = 7 : ""; // If sunday $fields = explode('-', $TheDate); if ($format == 'ymd') { $week['start'] = DateUtil::getDatetime_NextDay((1 - $dow), '%Y-%m-%d', $fields[0], $fields[1], $fields[2]); $week['end'] = DateUtil::getDatetime_NextDay((7 - $dow), "%Y-%m-%d %H:%M:%S", $fields[0], $fields[1], $fields[2], 23, 59, 59); } else { $week['start'] = DateUtil::getDatetime_NextDay((1 - $dow), '%d-%m-%y', $fields[0], $fields[1], $fields[2]); $week['end'] = DateUtil::getDatetime_NextDay((7 - $dow), "%d-%m-%y", $fields[0], $fields[1], $fields[2]); } return $week; }