Example #1
0
    function days()
    {
        $this_calfontcolor = str_replace(' ', '', $this->calfontcolor);
        $calfontcolor = !empty($this_calfontcolor) ? ' color:' . $this->calfontcolor . ';' : '';
        $this_bgcolor = str_replace(' ', '', $this->bgcolor);
        $bgcolor = !empty($this_bgcolor) ? ' background-color:' . $this->bgcolor . ';' : '';
        $this_bgimage = str_replace(' ', '', $this->bgimage);
        $bgimage = !empty($this_bgimage) ? ' background-image:url(\'' . $this->bgimage . '\');' : '';
        $this_bgimagerepeat = str_replace(' ', '', $this->bgimagerepeat);
        $bgimagerepeat = !empty($this_bgimagerepeat) ? ' background-repeat:' . $this->bgimagerepeat . ';' : '';
        $iCcal_style = '';
        if (!empty($this_calfontcolor) || !empty($this_bgcolor) || !empty($this_bgimage) || !empty($this_bgimagerepeat)) {
            $iCcal_style .= 'style="';
        }
        $iCcal_style .= $calfontcolor . $bgcolor . $bgimage;
        $iCcal_style .= $this_bgimagerepeat && $this_bgimage ? $bgimagerepeat : '';
        $iCcal_style .= empty($this_bgcolor) && empty($this_bgimage) ? ' background-color: transparent; background-image: none;' : '';
        $iCcal_style .= '"';
        // Verify Hex color strings
        $OneEventbgcolor = preg_match('/^#[a-f0-9]{6}$/i', $this->OneEventbgcolor) ? $this->OneEventbgcolor : '';
        $Eventsbgcolor = preg_match('/^#[a-f0-9]{6}$/i', $this->Eventsbgcolor) ? $this->Eventsbgcolor : '';
        echo '<div class="' . $this->template . ' iccalendar ' . $this->moduleclass_sfx . '" ' . $iCcal_style . ' id="' . $this->modid . '">';
        echo '<div id="mod_iccalendar_' . $this->modid . '">
			<div class="icagenda_header">' . $this->header_text . '
			</div>' . $this->nav . '
			<table id="icagenda_calendar" class="ic-table" style="width:100%;">
				<thead>
					<tr>
						<th style="width:14.2857143%;background:' . $this->colbg[0] . ';">' . JText::_($this->weekdays[$this->day[0] - 1]) . '</th>
						<th style="width:14.2857143%;background:' . $this->colbg[1] . ';">' . JText::_($this->weekdays[$this->day[1] - 1]) . '</th>
						<th style="width:14.2857143%;background:' . $this->colbg[2] . ';">' . JText::_($this->weekdays[$this->day[2] - 1]) . '</th>
						<th style="width:14.2857143%;background:' . $this->colbg[3] . ';">' . JText::_($this->weekdays[$this->day[3] - 1]) . '</th>
						<th style="width:14.2857143%;background:' . $this->colbg[4] . ';">' . JText::_($this->weekdays[$this->day[4] - 1]) . '</th>
						<th style="width:14.2857143%;background:' . $this->colbg[5] . ';">' . JText::_($this->weekdays[$this->day[5] - 1]) . '</th>
						<th style="width:14.2857143%;background:' . $this->colbg[6] . ';">' . JText::_($this->weekdays[$this->day[6] - 1]) . '</th>
					</tr>
				</thead>
		';
        switch ($this->data[1]['week']) {
            case $this->day[0]:
                break;
            case $this->day[1]:
                echo '<tr><td colspan="1"></td>';
                break;
            case $this->day[2]:
                echo '<tr><td colspan="2"></td>';
                break;
            case $this->day[3]:
                echo '<tr><td colspan="3"></td>';
                break;
            case $this->day[4]:
                echo '<tr><td colspan="4"></td>';
                break;
            case $this->day[5]:
                echo '<tr><td colspan="5"></td>';
                break;
            case $this->day[6]:
                echo '<tr><td colspan="6"></td>';
                break;
            default:
                echo '<tr><td colspan="' . ($this->data[1]['week'] - $this->firstday) . '"></td>';
                break;
        }
        foreach ($this->data as $d) {
            $stamp = new day($d);
            switch ($stamp->week) {
                case $this->day[0]:
                    echo '<tr><td style="background:' . $this->colbg[0] . ';">';
                    break;
                case $this->day[1]:
                    echo '<td style="background:' . $this->colbg[1] . ';">';
                    break;
                case $this->day[2]:
                    echo '<td style="background:' . $this->colbg[2] . ';">';
                    break;
                case $this->day[3]:
                    echo '<td style="background:' . $this->colbg[3] . ';">';
                    break;
                case $this->day[4]:
                    echo '<td style="background:' . $this->colbg[4] . ';">';
                    break;
                case $this->day[5]:
                    echo '<td style="background:' . $this->colbg[5] . ';">';
                    break;
                case $this->day[6]:
                    echo '<td style="background:' . $this->colbg[6] . ';">';
                    break;
                default:
                    echo '<td>';
                    break;
            }
            $count_events = count($stamp->events);
            if ($OneEventbgcolor && $OneEventbgcolor != ' ' && $count_events == '1') {
                $bg_day = $OneEventbgcolor;
            } elseif ($Eventsbgcolor && $Eventsbgcolor != ' ' && $count_events > '1') {
                $bg_day = $Eventsbgcolor;
            } else {
                $bg_day = isset($stamp->events[0]['cat_color']) ? $stamp->events[0]['cat_color'] : '#d4d4d4';
            }
            $bgcolor = iCColor::getBrightness($bg_day);
            $bgcolor = $bgcolor == 'bright' ? 'ic-bright' : 'ic-dark';
            $order = 'first';
            $multi_events = isset($stamp->events[1]['cat_color']) ? 'icmulti' : '';
            // Ordering by time New Theme Packs (since 3.2.9)
            $events = $stamp->events;
            // Option for Ordering is not yet finished. This developpement is in brainstorming...
            $ictip_ordering = '1';
            $ictip_ordering = $this->ictip_ordering;
            if ($ictip_ordering == '1_ASC-1_ASC' || $ictip_ordering == '1_ASC-1_DESC') {
                $ictip_ordering = '1_ASC';
            }
            if ($ictip_ordering == '2_ASC-2_ASC' || $ictip_ordering == '2_ASC-2_DESC') {
                $ictip_ordering = '2_ASC';
            }
            if ($ictip_ordering == '1_DESC-1_ASC' || $ictip_ordering == '1_DESC-1_DESC') {
                $ictip_ordering = '1_DESC';
            }
            if ($ictip_ordering == '2_DESC-2_ASC' || $ictip_ordering == '2_DESC-2_DESC') {
                $ictip_ordering = '2_DESC';
            }
            // Create Functions for Ordering
            // Default $newfunc_1_ASC_2_ASC - edited 2015-07-01 to fix ordering by Time when am/pm
            $newfunc_1_ASC_2_ASC = create_function('$a, $b', 'if ($a["time"] == $b["time"]){ return strcasecmp($a["cat_title"], $b["cat_title"]); } else { return strcasecmp(date("H:i", strtotime($a["time"])), date("H:i", strtotime($b["time"]))); }');
            $newfunc_1_ASC_2_DESC = create_function('$a, $b', 'if ($a["time"] == $b["time"]){ return strcasecmp($b["cat_title"], $a["cat_title"]); } else { return strcasecmp($a["time"], $b["time"]); }');
            $newfunc_1_DESC_2_ASC = create_function('$a, $b', 'if ($a["time"] == $b["time"]){ return strcasecmp($a["cat_title"], $b["cat_title"]); } else { return strcasecmp($b["time"], $a["time"]); }');
            $newfunc_1_DESC_2_DESC = create_function('$a, $b', 'if ($a["time"] == $b["time"]){ return strcasecmp($b["cat_title"], $a["cat_title"]); } else { return strcasecmp($b["time"], $a["time"]); }');
            $newfunc_2_ASC_1_ASC = create_function('$a, $b', 'if ($a["cat_title"] == $b["cat_title"]){ return strcasecmp($a["time"], $b["time"]); } else { return strcasecmp($a["cat_title"], $b["cat_title"]); }');
            $newfunc_2_ASC_1_DESC = create_function('$a, $b', 'if ($a["cat_title"] == $b["cat_title"]){ return strcasecmp($b["time"], $a["time"]); } else { return strcasecmp($a["cat_title"], $b["cat_title"]); }');
            $newfunc_2_DESC_1_ASC = create_function('$a, $b', 'if ($a["cat_title"] == $b["cat_title"]){ return strcasecmp($a["time"], $b["time"]); } else { return strcasecmp($b["cat_title"], $a["cat_title"]); }');
            $newfunc_2_DESC_1_DESC = create_function('$a, $b', 'if ($a["cat_title"] == $b["cat_title"]){ return strcasecmp($b["time"], $a["time"]); } else { return strcasecmp($b["cat_title"], $a["cat_title"]); }');
            $newfunc_1_ASC = create_function('$a, $b', 'return strcasecmp($a["time"], $b["time"]);');
            $newfunc_2_ASC = create_function('$a, $b', 'return strcasecmp($a["cat_title"], $b["cat_title"]);');
            $newfunc_1_DESC = create_function('$a, $b', 'return strcasecmp($b["time"], $a["time"]);');
            $newfunc_2_DESC = create_function('$a, $b', 'return strcasecmp($b["cat_title"], $a["cat_title"]);');
            // Order by time - Old Theme Packs (before 3.2.9) : Update Theme Pack to get all options
            usort($stamp->events, $newfunc_1_ASC_2_ASC);
            // Time ASC and if same time : Category Title ASC (default)
            if ($ictip_ordering == '1_ASC-2_ASC') {
                usort($events, $newfunc_1_ASC_2_ASC);
            }
            // Time ASC and if same time : Category Title DESC
            if ($ictip_ordering == '1_ASC-2_DESC') {
                usort($events, $newfunc_1_ASC_2_DESC);
            }
            // Time DESC and if same time : Category Title ASC
            if ($ictip_ordering == '1_DESC-2_ASC') {
                usort($events, $newfunc_1_DESC_2_ASC);
            }
            // Time DESC and if same time : Category Title DESC
            if ($ictip_ordering == '1_DESC-2_DESC') {
                usort($events, $newfunc_1_DESC_2_DESC);
            }
            // Category Title ASC and if same category : Time ASC
            if ($ictip_ordering == '2_ASC-1_ASC') {
                usort($events, $newfunc_2_ASC_1_ASC);
            }
            // Category Title ASC and if same category : Time DESC
            if ($ictip_ordering == '2_ASC-1_DESC') {
                usort($events, $newfunc_2_ASC_1_DESC);
            }
            // Category Title DESC and if same category : Time ASC
            if ($ictip_ordering == '2_DESC-1_ASC') {
                usort($events, $newfunc_2_DESC_1_ASC);
            }
            // Category Title DESC and if same category : Time DESC
            if ($ictip_ordering == '2_DESC-1_DESC') {
                usort($events, $newfunc_2_DESC_1_DESC);
            }
            // If main ordering and sub-ordering on Time : set TIME ASC (with no sub-ordering)
            if ($ictip_ordering == '1_ASC') {
                usort($events, $newfunc_1_ASC);
            }
            // If main ordering and sub-ordering on Category Title : set CATEGORY TITLE ASC (with no sub-ordering)
            if ($ictip_ordering == '2_ASC') {
                usort($events, $newfunc_2_ASC);
            }
            // Load template for day infotip
            require $this->t_day;
            switch ('week') {
                case $this->day[6]:
                    echo '</td></tr>';
                    break;
                default:
                    echo '</td>';
                    break;
            }
        }
        switch ($stamp->week) {
            case $this->day[6]:
                break;
            default:
                echo '<td colspan="' . (7 - $stamp->week) . '"></td></tr>';
                break;
        }
        echo '</table></div>';
        echo '</div>';
    }
Example #2
0
 /**
  * Function to get brightness of hexadecimal color
  *
  * @access	public static
  * @param	color in hexadecimal ('#xxxxxx')
  * @return	string ('dark' or 'bright')
  *
  * @since   1.0.0
  */
 public static function getBrightness($color)
 {
     if (!is_array($color) && preg_match("/^[#]([0-9a-fA-F]{6})\$/", $color) && strlen($color) == 7) {
         $get_RGB = iCColor::hex_to_rgb($color);
         $RGB = explode(",", $get_RGB);
         $RGBa = $RGB[0];
         $RGBb = $RGB[1];
         $RGBc = $RGB[2];
         $sum = $RGBa + $RGBb + $RGBc;
         if ($sum > '384') {
             $brightness = 'bright';
         } else {
             $brightness = 'dark';
         }
         return $brightness;
     } else {
         return false;
     }
 }