public static function cgsi_getimages($params, $content, &$smarty, $repeat)
 {
     if (!$content) {
         return;
     }
     $mod = cms_utils::get_module('CGSmartImage');
     $old_errorval = libxml_use_internal_errors(true);
     $dom = new CGDomDocument();
     $dom->strictErrorChecking = FALSE;
     $dom->validateOnParse = FALSE;
     if (function_exists('mb_convert_encoding')) {
         $content = mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8');
     }
     $dom->loadHTML($content);
     $imgs = $dom->GetElementsByTagName('img');
     if (is_object($imgs) && $imgs->length) {
         $out = array();
         for ($i = 0; $i < $imgs->length; $i++) {
             $node = $imgs->item($i);
             $sxe = simplexml_import_dom($node);
             $rec = array();
             $rec['tag'] = $sxe->asXML();
             foreach ($sxe->attributes() as $name => $value) {
                 $value = (string) $value;
                 if ($value == '') {
                     continue;
                 }
                 $rec[$name] = $value;
             }
             $out[] = $rec;
         }
         if (isset($params['assign'])) {
             $smarty->assign($params['assign'], $out);
         }
     }
     $imagesonly = cms_to_bool(get_parameter_value($params, 'imagesonly'));
     $nocontent = cms_to_bool(get_parameter_value($params, 'nocontent'));
     if (!$nocontent) {
         if ($imagesonly) {
             $content = '';
             foreach ($out as $rec) {
                 $content .= $rec['tag'];
             }
         }
         return $content;
     }
 }
 public static function link_tag($params)
 {
     $url = get_parameter_value($params, 'url');
     $text = get_parameter_value($params, 'text', $url);
     $linkclass = get_parameter_value($params, 'linkclass');
     // build the tag.
     $output = '<a href="' . $url . '" title="' . $text . '"';
     if ($linkclass) {
         $output .= ' class="' . $linkclass . '"';
     }
     $output .= '>';
     if (isset($params['image'])) {
         if (isset($params['imgclass'])) {
             $params['class'] = $imgclass;
         }
         $params['alt'] = $text;
         $output .= self::img_tag($params);
     } else {
         $output .= $text;
     }
     $output .= '</a>';
     return $output;
 }
    }
}
$inline = isset($params['inline']) ? (int) $params['inline'] : 0;
$first_day_of_week = $this->GetPreference('firstdayofweek', 1);
$category = html_entity_decode(html_entity_decode(get_parameter_value($params, 'category')));
$limit = get_parameter_value($params, 'limit', 1000);
$limit = min(1000, $limit);
$reverse = get_parameter_value($params, 'reverse', false);
$use_session = get_parameter_value($params, 'use_session');
if ($use_session) {
    $sessionkey = $use_session . cgcalendar_utils::get_sessionkey($params);
    $year = (int) $this->session_get($sessionkey . 'year', $year);
    $week = (int) $this->session_get($sessionkey . 'week', $week);
}
$year = (int) get_parameter_value($params, 'year', $year);
$week = (int) get_parameter_value($params, 'week', $week);
if ($sessionkey) {
    $this->session_put($sessionkey . 'year', $year);
    $this->session_put($sessionkey . 'week', $week);
    $inline = true;
}
// fix up week and year
if ($week < 1) {
    $week = 53;
    $year--;
} else {
    if ($week > 53) {
        $week = 1;
        $year++;
    }
}
            $sql = "INSERT INTO " . $this->events_to_categories_table_name . " (category_id, event_id) VALUES (?,?)";
            $db->Execute($sql, array($category_id, $event['event_id']));
            //echo $sql;
        }
    }
}
$fieldtext = '';
$fields = $this->GetFields();
$sql = "DELETE FROM " . $this->event_field_values_table_name . " WHERE event_id = ?";
$result = $db->Execute($sql, array($event['event_id']));
$customfieldsvalues = array();
foreach ($fields as $field) {
    $fieldname = $field['field_name'];
    // Replace spaces with underbars for the form parameter (a bit of an ikky hack I know, but I can well imagine folk defining custom fields with spaces in the name) Perhaps it would have been better if custom fields also had a numeric key - hohum live and learn!
    $safefieldname = str_replace(" ", "_", $fieldname);
    $field_value = get_parameter_value($params, 'field_' . $safefieldname, '');
    $sql = "INSERT INTO " . $this->event_field_values_table_name . " (field_name, event_id, field_value) VALUES (?,?,?)";
    if ($field_value) {
        $result = $db->Execute($sql, array($fieldname, $event['event_id'], $field_value));
    }
    $customfieldsvalues[] = array($fieldname, $event['event_id'], $field_value);
    if ($field['field_searchable']) {
        $fieldtext .= $field_value . ' ';
    }
}
//////////////////////////////////////////////////////////////
// Update Search
/////////////////////////////////////////////////////////////
$search = cms_utils::get_search_module();
if ($search != FALSE) {
    $text = "{$event['event_title']} {$event['event_summary']} {$event['event_details']}";
 public static function cge_message($params, $smarty)
 {
     $key = get_parameter_value($params, 'key');
     if ($key) {
         if (isset($params['value'])) {
             $val = trim($params['value']);
             cge_message::set($key, $val);
         } else {
             $val = cge_message::get($key);
             if (isset($params['assign'])) {
                 $smarty->assign($params['assign'], $val);
                 return;
             }
             return $val;
         }
     }
 }
        $this->SetPreference('overlap_action', $overlap_action);
        $this->SetPreference('firstdayofweek', $firstdayofweek);
        $this->SetPreference('use_twelve_hour_clock', $use_twelve_hour_clock);
        $this->SetPreference('defaultcalendarpage', $_POST['parent_id']);
        $this->SetPreference('default_category', $default_category);
        $this->SetPreference('force_category', $force_category);
        $this->SetPreference('showpastyears', $showpastyears);
        $this->SetPreference('showfutureyears', $showfutureyears);
        $this->SetPreference('hidesummary', $hidesummary);
        $this->SetPreference('hidecontent', $hidecontent);
        $this->SetPreference('uploaddirectory', $uploaddirectory);
        $this->SetPreference('uploadfiletypes', $uploadfiletypes);
        $this->SetPreference('uploadunique', $uploadunique);
        $this->SetPreference('friendlyname', trim($params['friendlyname']));
        $this->SetPreference('dflt_fgcolor', trim($params['dflt_fgcolor']));
        $this->SetPreference('dflt_bgcolor', trim($params['dflt_bgcolor']));
        $this->SetPreference('ical_holidays', \cge_param::get_string($params, 'ical_holidays'));
        $this->SetPreference('url_prefix', get_parameter_value($params, 'url_prefix', 'calendar'));
        $this->SetPreference('dflt_alldayevent', get_parameter_value($params, 'dflt_alldayevent', 0));
        $this->SetPreference('holiday_fgcolor', trim($params['holiday_fgcolor']));
        $this->SetPreference('holiday_bgcolor', trim($params['holiday_bgcolor']));
        $start_time = '';
        $start_time = get_parameter_value($params, 'dflt_starttime_Hour', 12) . ':' . get_parameter_value($params, 'dflt_starttime_Minute', 00);
        $this->SetPreference('dflt_starttime', $start_time);
        if (isset($params['frontend_group'])) {
            $this->SetPreference('frontend_group', $params['frontend_group']);
        }
        $this->SetPreference('frontend_redirectpage', $frontend_redirectpage);
    }
    $this->RedirectToTab($id);
}
if (!$feu) {
    echo '<h3><font color="red">' . $this->Lang('error_nofeu') . "</font></h3>\n";
    return;
} else {
    if (!$feu->LoggedIn()) {
        echo '<h3><font color="red">' . $this->Lang('error_feu_loggedin') . "</font></h3>\n";
        return;
    }
}
//
// initialization
//
$feu_uid = $feu->LoggedInId();
$thetemplate = $this->GetPreference(CGCALENDAR_PREF_DFLTEDITEVENT_TEMPLATE);
$thetemplate = \cge_param::get_string($params, 'editeventtemplate', $thetemplate);
$event_id = get_parameter_value($params, 'event_id', -1);
$event = $this->GetEvent($event_id, $feu_uid);
$fields = $this->GetFields();
$categories = $this->GetCategories();
$policy = $this->GetPreference('overlap_polciy', 'all');
$force_category = $this->GetPreference('force_category', 0);
$destpage = $returnid;
if (isset($params['return_id'])) {
    $destpage = (int) $params['return_id'];
} else {
    $tmp = $this->GetPreference('frontend_redirectpage', '');
    if ($tmp) {
        $tmp = $this->ProcessTemplateFromData($tmp);
        if ($tmp) {
            $tmp = $this->resolve_alias_or_id($tmp);
            if ($tmp) {
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Or read it online: http://www.gnu.org/licenses/licenses.html#GPL
#
#-------------------------------------------------------------------------
#END_LICENSE
if (!isset($gCms)) {
    exit;
}
$events_table_name = $this->events_table_name;
$event_id = (int) get_parameter_value($params, 'event_id', 'next');
$db = cmsms()->GetDb();
if ($event_id == 'next') {
    $start = date('Y-m-d H:i:s');
    // start now !
    $sql = "SELECT DISTINCT event_id FROM {$events_table_name} ";
    $sql .= "WHERE event_date_start > '{$start}' OR event_date_end > '{$start}'";
    $sql .= ' LIMIT 1';
    $event_id = $db->GetOne($sql);
} else {
    if ((int) $event_id > 0) {
        // nothing.
    } else {
        // no event
        echo '<div class="calendar-error">' . $this->Lang('error_event_not_found', $event_id) . '</div>';
        return;
Esempio n. 9
0
 $now = $db->DbTimeStamp(time());
 $query1 .= "(" . $db->IfNull('start_time', $db->DBTimeStamp(1)) . " < " . $now . ") ";
 $query2 .= "(" . $db->IfNull('start_time', $db->DBTimeStamp(1)) . " < " . $now . ") ";
 if (!isset($params['showall']) || $params['showall'] == 0) {
     if (isset($params['showarchive']) && $params['showarchive'] != 0) {
         // get articles that are expired
         $query1 .= " AND (end_time < " . $now . ") ";
         $query2 .= " AND (end_time < " . $now . ") ";
     } else {
         // get articles with either no expiry, or an end time greater than now
         $query1 .= " AND ((" . $db->IfNull('end_time', $db->DBTimeStamp(1)) . " = " . $db->DBTimeStamp(1) . ") OR (end_time > " . $now . ")) ";
         $query2 .= " AND ((" . $db->IfNull('end_time', $db->DBTimeStamp(1)) . " = " . $db->DBTimeStamp(1) . ") OR (end_time > " . $now . ")) ";
     }
 }
 $sortrandom = false;
 $sortby = trim(get_parameter_value($params, 'sortby', 'news_date'));
 switch ($sortby) {
     case 'news_category':
         if (isset($params['sortasc']) && strtolower($params['sortasc']) == 'true') {
             $query1 .= "ORDER BY mnc.long_name ASC, mn.news_date ";
         } else {
             $query1 .= "ORDER BY mnc.long_name DESC, mn.news_date ";
         }
         break;
     case 'random':
         $query1 .= "ORDER BY RAND() ";
         $sortrandom = true;
         break;
     case 'summary':
     case 'news_data':
     case 'news_category':
function module_action_link($params, &$smarty)
{
    $gCms = cmsms();
    $mid = 'm1_';
    $inline = FALSE;
    $module = $smarty->get_template_vars('nmodule');
    if (!$module) {
        $module = $smarty->get_template_vars('actionmodule');
    }
    $module = get_parameter_value($params, 'module', $module);
    if (!$module) {
        return;
    }
    unset($params['module']);
    $obj = cms_utils::get_module($module);
    if (!is_object($obj)) {
        return;
    }
    $text = $module;
    if (isset($params['text'])) {
        $text = trim($params['text']);
        unset($params['text']);
    }
    $title = '';
    if (isset($params['title'])) {
        $title = trim($params['title']);
        unset($params['title']);
    }
    $confmessage = '';
    if (isset($params['confmessage'])) {
        $confmessage = trim($params['confmessage']);
        unset($params['confmessage']);
    }
    $image = '';
    if (isset($params['image'])) {
        $image = trim($params['image']);
        unset($params['image']);
    }
    $class = 'systemicon';
    if (isset($params['class'])) {
        $class = trim($params['class']);
        unset($params['class']);
    }
    $action = 'default';
    if (isset($params['action'])) {
        $action = $params['action'];
        unset($params['action']);
    }
    if (isset($params['id'])) {
        $mid = $params['id'];
        $inline = TRUE;
        unset($params['id']);
    }
    $imageonly = false;
    if (isset($params['imageonly'])) {
        $imageonly = true;
        unset($params['imageonly']);
    }
    $pageid = cms_utils::get_current_pageid();
    if (isset($params['page'])) {
        // convert the page alias to an id
        $manager = $gCms->GetHierarchyManager();
        $node = $manager->sureGetNodeByAlias($params['page']);
        if (isset($node)) {
            $content = $node->GetContent();
            if (isset($content)) {
                $pageid = $content->Id();
            }
        } else {
            $node = $manager->sureGetNodeById($params['page']);
            if (isset($node)) {
                $pageid = $params['detailpage'];
            }
        }
        unset($params['page']);
    }
    $urlonly = cge_utils::to_bool(cge_utils::get_param($params, 'urlonly', false));
    if ($urlonly) {
        $urlonly = true;
        unset($params['urlonly']);
    }
    $jsfriendly = cge_utils::to_bool(cge_utils::get_param($params, 'jsfriendly', false));
    if ($jsfriendly) {
        $jsfriendly = true;
        $urlonly = true;
        unset($params['jsfriendly']);
    }
    $forjs = cge_utils::to_bool(cge_utils::get_param($params, 'forjs', false));
    if ($forjs) {
        $jsfriendly = true;
        $urlonly = true;
        unset($params['forjs']);
    }
    $forajax = cge_utils::to_bool(cge_utils::get_param($params, 'forajax', false));
    if ($forajax) {
        $jsfriendly = true;
        $urlonly = true;
        $forajax = true;
        unset($params['forajax']);
    }
    $assign = '';
    if (isset($params['assign'])) {
        $assign = trim($params['assign']);
        unset($params['assign']);
    }
    $addtext = '';
    if ($title) {
        $addtext = 'title="' . $title . '"';
    }
    if (!empty($image) && method_exists($obj, 'CreateImageLink') && $urlonly == false) {
        $output = $obj->CreateImageLink($mid, $action, $pageid, $text, $image, $params, $class, $confmessage, $imageonly, FALSE, $addtext);
    } else {
        $output = $obj->CreateLink($mid, $action, $pageid, $text, $params, $confmessage, $urlonly, $inline, $addtext);
        if ($urlonly && $jsfriendly) {
            $output = str_replace('amp;', '', $output);
        }
        if ($forajax) {
            if (strpos($output, '?') === FALSE) {
                $output .= '?showtemplate=false';
            } else {
                $output .= '&showtemplate=false';
            }
        }
    }
    // all done
    if (!empty($assign)) {
        $smarty->assign($assign, $output);
        return;
    }
    return $output;
}
    // we use a unique key, based on most parameters (except the ones that can change)
    // and only extract items from the session that can change (like dates, or page numbers).
    $inline = 1;
    $sessionkey = $use_session . cgcalendar_utils::get_sessionkey($params);
    $page = $this->session_get($sessionkey . 'page', $page);
}
$category = html_entity_decode(html_entity_decode(get_parameter_value($params, 'category', $category)));
$pastitems = get_parameter_value($params, 'pastitems', 0);
$page = get_parameter_value($params, 'page', $page);
if ($pastitems) {
    $expr = '<';
    $reverse = true;
}
$limit = get_parameter_value($params, 'limit', 1000);
$inline = get_parameter_value($params, 'inline', $inline);
$reverse = get_parameter_value($params, 'reverse', $reverse);
if ($sessionkey) {
    //this remembers the page number for the next time we visit this page.
    $this->session_put($sessionkey . 'page', $page);
}
// build the query
$sql2 = "SELECT E.event_id FROM {$events_table_name} E\n";
if (!empty($category)) {
    $sql2 .= "INNER JOIN {$events_to_categories_table_name} EC ON E.event_id = EC.event_id\n              INNER JOIN {$categories_table_name} C ON EC.category_id = C.category_id";
}
$sorting = $reverse == 'true' ? 'DESC' : 'ASC';
$start = $db->DbTimeStamp(time());
if (isset($params['displayforday'])) {
    $start = $db->DbTimeStamp(mktime(00, 00, 30));
}
$txt = "WHERE (E.event_date_start {$expr} {$start} OR (E.event_date_end {$expr} {$start} AND COALESCE(E.event_date_end,'****') != '****'))";
    $tmp = $this->resolve_alias_or_id($params['detailpage']);
    if ($tmp) {
        $detailpage = (int) $tmp;
    }
}
$inline = get_parameter_value($params, 'inline', 0);
$category = html_entity_decode(html_entity_decode(get_parameter_value($params, 'category')));
$limit = get_parameter_value($params, 'limit', 1000);
$limit = min($limit, 1000);
$reverse = get_parameter_value($params, 'reverse', false);
$use_session = get_parameter_value($params, 'use_session', true);
if ($use_session) {
    $sessionkey = $use_session . cgcalendar_utils::get_sessionkey($params);
    $year = $this->session_get($sessionkey . 'year');
}
$year = get_parameter_value($params, 'year', date('Y'));
if ($sessionkey) {
    $this->session_put($sessionkey . 'year', $year);
    $inline = 1;
}
// basic information about dates
$prev_year['timestamp'] = strtotime("-1 year", mktime(0, 0, 0, 1, 1, $year));
$prev_year['year'] = date('Y', $prev_year['timestamp']);
$next_year['timestamp'] = strtotime("+1 year", mktime(0, 0, 0, 1, 1, $year));
$next_year['year'] = date('Y', $next_year['timestamp']);
$last_day_of_year = mktime(0, 0, 0, 1, 0, $next_year['year']);
$start = mktime(0, 0, 0, 1, 1, $year);
$end = mktime(23, 59, 59, 12, 31, $year);
$idlist = $db->GetCol(cgcalendar_utils::get_query($start, $end, $category, $reverse));
$idlist = array_slice($idlist, 0, $limit);
$loader = new cgc_event_loader($id, $idlist, $detailpage, $reverse);
Esempio n. 13
0
# in any Non GPL version of CMS Made simple, or in any version of CMS
# Made simple that does not indicate clearly and obviously in its admin
# section that the site was built with CMS Made simple.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Or read it online: http://www.gnu.org/licenses/licenses.html#GPL
#
#-------------------------------------------------------------------------
#END_LICENSE
$display = get_parameter_value($params, 'display', 'fullcalendar');
switch ($display) {
    case 'calendar':
        require __DIR__ . '/function.displaycalendar.php';
        break;
    case 'event':
        require __DIR__ . '/function.displayevent.php';
        break;
    case 'list':
        require __DIR__ . '/function.displaylist.php';
        break;
    case 'weeklist':
        require __DIR__ . '/function.displayweeklist.php';
        break;
    case 'yearlist':
        require __DIR__ . '/function.displayyearlist.php';
 function plugin_anchorlink($params, &$smarty)
 {
     $name = get_parameter_value($params, 'n');
     $name = get_parameter_value($params, 'name', $name);
     $assign = trim(get_parameter_value($params, 'assign'));
     $urlonly = get_parameter_value($params, 'u');
     $urlonly = cms_to_bool(get_parameter_value($params, 'urlonly', $urlonly));
     $text = get_parameter_value($params, 'text', $name);
     unset($params['name'], $params['n'], $params['assign'], $params['u'], $params['urlonly'], $params['text']);
     // start the work
     $out = $url = null;
     if ($name) {
         $url = cgsimple::anchor_url($name);
     }
     if ($urlonly) {
         $out = $url;
     } else {
         // build a link with all the leftover params (don't filter them, there are lots of valid params for a link).
         $tpl = " %s=\"%s\"";
         $out = '<a';
         $out .= sprintf($tpl, 'href', $url);
         foreach ($params as $key => $val) {
             $out .= " {$key}=\"{$val}\"";
         }
         $out .= '>' . $text . '</a>';
     }
     if ($assign) {
         $smarty->assign($assign, $out);
     } else {
         return $out;
     }
 }
    // and only extract items from the session that can change (like dates, or page numbers).
    $sessionkey = $use_session . cgcalendar_utils::get_sessionkey($params);
    $month = $this->session_get($sessionkey . 'cur_month', $month);
    $year = $this->session_get($sessionkey . 'cur_year', $year);
}
// get selected data from parameters
$year_list = array();
for ($i = date('Y') - 5; $i <= date('Y') + 2; $i++) {
    $year_list[$i] = $i;
}
$smarty->assign('year_list', $year_list);
$month = get_parameter_value($params, 'month', $month);
$year = get_parameter_value($params, 'year', $year);
$category = html_entity_decode(html_entity_decode(get_parameter_value($params, 'category', $category)));
$inline = get_parameter_value($params, 'inline', $inline);
$p_detailpage = get_parameter_value($params, 'detailpage', $p_detailpage);
if ($p_detailpage) {
    $tmp = $this->resolve_alias_or_id($p_detailpage);
    if ($tmp > 0) {
        $detailpage = $tmp;
    }
}
if ($month == -1) {
    // fallback to current month and year
    $month = date('n');
    $year = date('Y');
}
if (!empty($sessionkey)) {
    // store them back in the session.
    $this->session_put($sessionkey . 'cur_month', $month);
    $this->session_put($sessionkey . 'cur_year', $year);
 public static function cge_array_pop($params, &$smarty)
 {
     if (!isset($params['array'])) {
         return;
     }
     $arr = get_parameter_value($params, 'array');
     if (!$arr) {
         return;
     }
     if (!cge_tmpdata::exists($arr)) {
         return;
     }
     $data = cge_array::get($arr);
     if (!is_array($data)) {
         return;
     }
     $ret = array_pop($data);
     cge_tmpdata::set($arr, $data);
     if (isset($params['assign'])) {
         $smarty->assign(trim($params['assign']), $ret);
         return;
     }
     return $ret;
 }
        $detailpage = $tmp;
    }
}
$sessionkey = null;
$category = null;
$category = html_entity_decode(html_entity_decode(get_parameter_value($params, 'category', $category)));
$limit = get_parameter_value($params, 'limit', 1000);
$limit = min($limit, 1000);
$inline = get_parameter_value($params, 'inline', -1);
$reverse = get_parameter_value($params, 'reverse', false);
// defaults for y/md/d (default to current month view).
$year = date('Y');
$month = date('m');
$day = -1;
// get y/m/d from session
$use_session = get_parameter_value($params, 'use_session');
if ($use_session) {
    $sessionkey = $use_session . cgcalendar_utils::get_sessionkey($params);
    list($year, $month, $day) = cgcalendar_utils::to_ymd($this->session_get($sessionkey . 'date', $thedate));
}
// get y/m/d from params
if (isset($params['date'])) {
    list($year, $month, $day) = cgcalendar_utils::to_ymd($params['date']);
} else {
    $year = (int) cge_utils::get_param($params, 'year', $year);
    $month = (int) cge_utils::get_param($params, 'month', $month);
    $day = (int) cge_utils::get_param($params, 'day', $day);
}
$thedate = sprintf("%d-%d", (int) $year, (int) $month);
if ($day > 0) {
    $thedate .= sprintf('-%d', (int) $day);