Ejemplo n.º 1
0
 /**
  * Registers necessary JS and passes is the proper arguments
  * Checks for POST
  */
 public function registerJS()
 {
     Yii::app()->clientScript->registerCoreScript('cookie', CClientScript::POS_READY);
     Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/js/LoginThemeHelper.js', CClientScript::POS_END);
     /* This part will create a part of the theme selector specific to the current theme */
     if ($this->currentTheme == ThemeGenerator::$defaultLight) {
         $theme = ThemeGenerator::loadDefault($this->nextTheme);
     } else {
         $theme = ThemeGenerator::loadDefault($this->currentTheme);
     }
     if (!isset($theme['background'])) {
         $theme['background'] = '#000';
     }
     $themeBG = array($theme['background'], X2Color::brightness($theme['background'], -0.1), $theme['background']);
     $JSON = array('themeColorCookie' => self::LOGIN_BACKGROUND_COOKIE, 'cookieLength' => self::$cookieLength, 'open' => isset($_POST[self::LOGIN_THEME_COOKIE]), 'currentColor' => $this->currentColor, 'currentThemeBG' => $themeBG);
     $JSON = CJSON::encode($JSON);
     Yii::app()->clientScript->registerScript('LoginThemeHelperJS', "\n\t\t\tnew x2.LoginThemeHelper({$JSON});\n\t\t", CClientScript::POS_END);
 }
Ejemplo n.º 2
0
 public function formatActionToEvent($action, $id)
 {
     if (!($action->visibility >= 1 || $action->assignedTo == Yii::app()->user->name || Yii::app()->params->isAdmin)) {
         // admin sees all
         return false;
     }
     $linked = !empty($action->associationType) && strtolower($action->associationType) != 'none' && class_exists(X2Model::getModelName($action->associationType));
     if ($linked) {
         $associatedModel = X2Model::getMOdelOfTypeWithId(X2Model::getModelName($action->associationType), $action->associationId);
         if ($associatedModel) {
             $associationUrl = $associatedModel->getUrl();
         } else {
             $associationUrl = '';
         }
     }
     $title = $action->shortActionText;
     //Email formatting
     $title = preg_replace('/<b>/', '', $title);
     $title = preg_replace('/<\\/b>/', '', $title);
     $title = preg_replace('/\\n\\n/', "\n", $title);
     $title = preg_replace('/<!--EndSig-->/', '', $title);
     $title = preg_replace('/<!--BeginOpenedEmail-->/', '', $title);
     $title = preg_replace('/<!--BeginSignature-->/', '', $title);
     if (in_array($action->type, array('email', 'emailFrom', 'email_quote', 'email_invoice', 'emailOpened', 'emailOpened_quote', 'emailOpened_invoice'))) {
         $title = 'Email: ' . $title;
     }
     $event = array('title' => $title, 'description' => $title, 'start' => date('Y-m-d H:i', $action->dueDate), 'id' => $action->id, 'complete' => $action->complete, 'calendarAssignment' => $id, 'allDay' => false);
     if ($action->allDay) {
         $event['allDay'] = $action->allDay;
     }
     if ($action->color) {
         $event['color'] = $action->color;
     } else {
         $event['color'] = '#6389de';
         // old default color
         //$event['color'] = '#3a87ad';
     }
     static $brightnesses = array();
     if (!isset($brightnesses[$event['color']])) {
         $brightnesses[$event['color']] = X2Color::getColorBrightness($event['color']);
     }
     if ($brightnesses[$event['color']] < 115) {
         $event['textColor'] = 'white';
     }
     if ($action->type == 'event') {
         if ($action->completeDate) {
             $event['end'] = date('Y-m-d H:i', $action->completeDate);
         }
         $event['type'] = 'event';
         $event['associationType'] = $action->associationType;
     }
     $event['linked'] = $linked;
     if ($linked) {
         $event['associationType'] = $action->associationType;
         $event['associationUrl'] = $associationUrl;
         $event['associationName'] = $action->associationName;
     }
     $editable = X2CalendarPermissions::getEditableUserCalendarNames();
     // If it is a group id, we don't need to check this
     $userEditable = !is_int($id) && isset($editable[$id]);
     $event['editable'] = $userEditable && Yii::app()->user->checkAccess('ActionsUpdate', array('X2Model' => $action));
     return $event;
 }
Ejemplo n.º 3
0
    $defaultOpacity = Yii::app()->params->profile->pageOpacity / 100;
    Yii::app()->clientScript->registerScript('loadPageOpacity', "\n\t\t\$(document).ready(function() {\n\t\t\t\$('#page').fadeTo(0," . $defaultOpacity . ");\n\t\t});\n\t", CClientScript::POS_HEAD);
}
// check for background image, use it if one is set
if (empty(Yii::app()->params->profile->backgroundImg)) {
    $backgroundImg = CHtml::image('', '', array('id' => 'bg', 'style' => 'display:none;'));
} else {
    $backgroundImg = CHtml::image(Yii::app()->getBaseUrl() . '/uploads/' . Yii::app()->params->profile->backgroundImg, '', array('id' => 'bg'));
}
if (!empty(Yii::app()->params->profile->backgroundColor)) {
    $themeCss .= 'body {background-color:#' . Yii::app()->params->profile->backgroundColor . ";}\n";
    if (!empty($backgroundImg)) {
        $shadowRgb = 'rgb(0,0,0,0.5)';
        // use a black shadow if there is an image
    } else {
        $shadowColor = X2Color::hex2rgb(Yii::app()->params->profile->backgroundColor);
        // if there is no BG image, calculate a darker tone for the shadow
        foreach ($shadowColor as &$value) {
            $value = floor(0.5 * $value);
        }
        $shadowRgb = 'rgb(' . implode(',', $shadowColor) . ')';
    }
    $themeCss .= "#page {\n-moz-box-shadow: 0 0 30px {$shadowRgb};\n-webkit-box-shadow: 0 0 30px {$shadowRgb};\nbox-shadow: 0 0 30px {$shadowRgb};\n}\n";
}
if (!empty(Yii::app()->params->profile->menuBgColor)) {
    $themeCss .= '#main-menu-bar {background:#' . Yii::app()->params->profile->menuBgColor . ";}\n";
}
if (!empty(Yii::app()->params->profile->menuTextColor)) {
    $themeCss .= '#main-menu-bar ul a, #main-menu-bar ul span {color:#' . Yii::app()->params->profile->menuTextColor . ";}\n";
}
Yii::app()->clientScript->registerCss('applyTheme', $themeCss, 'screen', CClientScript::POS_HEAD);
Ejemplo n.º 4
0
 /**
  * @param type $fieldName
  * @param type $htmlOptions
  */
 public function renderInput($fieldName, $htmlOptions = array())
 {
     switch ($fieldName) {
         case 'color':
             $field = $this->getField($fieldName);
             $options = Dropdowns::getItems($field->linkType, null, false);
             $enableDropdownLegend = Yii::app()->settings->enableColorDropdownLegend;
             if ($enableDropdownLegend) {
                 $htmlOptions['options'] = array();
                 foreach ($options as $value => $label) {
                     $brightness = X2Color::getColorBrightness($value);
                     $fontColor = $brightness > 127.5 ? 'black' : 'white';
                     $htmlOptions['options'][$value] = array('style' => 'background-color: ' . $value . ';
                              color: ' . $fontColor);
                 }
             }
             return CHtml::activeDropDownList($this, $field->fieldName, $options, $htmlOptions);
         case 'priority':
             return CHtml::activeDropdownList($this, 'priority', self::getPriorityLabels());
         case 'associationType':
             return X2Html::activeMultiTypeAutocomplete($this, 'associationType', 'associationId', array('calendar' => Yii::t('app', 'Select an option')) + X2Model::getAssociationTypeOptions());
         case 'reminder':
             $reminderInput = parent::renderInput($fieldName, array('class' => 'reminder-checkbox'));
             $reminderInput .= X2Html::openTag('div', X2Html::mergeHtmlOptions($htmlOptions, array('class' => 'reminder-config'))) . Yii::t('actions', 'Create a notification reminder for {user} {time} before this {action} ' . 'is due', array('{user}' => CHtml::activeDropDownList($this, 'notificationUsers', array('me' => Yii::t('actions', 'me'), 'assigned' => Yii::t('actions', 'the assigned user'), 'both' => Yii::t('actions', 'me and the assigned user'))), '{time}' => CHtml::activeDropDownList($this, 'notificationTime', array(1 => Yii::t('actions', '1 minute'), 5 => Yii::t('actions', '5 minutes'), 10 => Yii::t('actions', '10 minutes'), 15 => Yii::t('actions', '15 minutes'), 30 => Yii::t('actions', '30 minutes'), 60 => Yii::t('actions', '1 hour'), 1440 => Yii::t('actions', '1 day'), 10080 => Yii::t('actions', '1 week'))), '{action}' => lcfirst(Modules::displayName(false, 'Actions')))) . '</div>';
             return $reminderInput;
         default:
             return parent::renderInput($fieldName, $htmlOptions);
     }
 }
Ejemplo n.º 5
0
    <div id='stage-member-lists-container-inner'>
<?php 
$modelTypes = array_flip(X2Model::$associationModels);
$recordNames = X2Model::getAllRecordNames();
?>
<div id='stage-member-prototype' style='display: none;'>
<?php 
// render a dummy item view so that it can be cloned on the client
$this->renderpartial('_dragAndDropItemView', array('data' => array('id' => null, 'name' => null), 'recordNames' => $recordNames, 'dummyPartial' => true, 'recordType' => 'contacts', 'workflow' => $model));
?>
</div>
<?php 
$colorGradients = array();
for ($i = 0; $i < sizeof($colors); $i++) {
    list($r, $g, $b) = X2Color::hex2rgb2($colors[$i][0]);
    list($r2, $g2, $b2) = X2Color::hex2rgb2($colors[$i][1]);
    $colorStr1 = "rgba({$r}, {$g}, {$b}, 0.65)";
    $colorStr2 = "rgba({$r2}, {$g2}, {$b2}, 0.65)";
    $colorGradients[] = 'background: ' . $colors[$i][0] . ';
        background: -moz-linear-gradient(top,    ' . $colorStr1 . ' 0%, ' . $colorStr2 . ' 100%);
        background: -webkit-linear-gradient(top,    ' . $colorStr1 . ' 0%, ' . $colorStr2 . ' 100%);
        background: -o-linear-gradient(top,        ' . $colorStr1 . ' 0%, ' . $colorStr2 . ' 100%);
        background: -ms-linear-gradient(top,        ' . $colorStr1 . ' 0%, ' . $colorStr2 . ' 100%);
        background: linear-gradient(to bottom, ' . $colorStr1 . ' 0%, ' . $colorStr2 . ' 100%);';
}
for ($i = 0; $i < count($stages); ++$i) {
    $stage = $stages[$i];
    ?>
    <div class='stage-members'>
    <div class='stage-member-staging-area'></div>
    <?php 
Ejemplo n.º 6
0
 /**
  * @param array $colors an array of color hex values, 1 for each stage 
  * @return array css color strings to be used for pipeline list item backgrounds
  */
 public static function getPipelineListItemColors($colors)
 {
     $listItemColors = array();
     for ($i = 1; $i <= count($colors); ++$i) {
         list($r, $g, $b) = X2Color::hex2rgb2($colors[$i - 1][0]);
         $listItemColors[$i - 1][] = "rgba({$r}, {$g}, {$b}, 0.20)";
         $listItemColors[$i - 1][] = "rgba({$r}, {$g}, {$b}, 0.12)";
     }
     return $listItemColors;
 }
Ejemplo n.º 7
0
 /**
  * Populates the array with different color option
  * @return array array filled with formatted css color strings
  */
 public static function generatePalette($preferences, $refresh = false)
 {
     $computedTheme = Yii::app()->cache->get(self::getCacheKey());
     if (!Yii::app()->user->isGuest && $computedTheme && !$refresh) {
         return $computedTheme;
     }
     $colors = $preferences;
     //Keys for smart text
     $colors['smart_text'] = '';
     $colors['smart_text2'] = '';
     if (isset($colors['backgroundImg']) && $colors['backgroundImg']) {
         $colors['background'] = '';
     }
     $settings = self::getSettingsList();
     foreach ($settings as $key) {
         if (!isset($colors[$key])) {
             $colors[$key] = '';
         }
         $value = $colors[$key];
         if (!preg_match("/#/", $value) && $value) {
             $colors[$key] = '#' . $value;
         }
         if (!preg_match('/_override$/', $key)) {
             $colors['darker_' . $key] = X2Color::brightness($value, -0.1, false);
             $colors['dark_' . $key] = X2Color::brightness($value, -0.05, false);
             $colors['brighter_' . $key] = X2Color::brightness($value, 0.1, false);
             $colors['bright_' . $key] = X2Color::brightness($value, 0.05, false);
             $colors['opaque_' . $key] = X2Color::opaque($value, 0.2);
         }
         $colors['light_' . $key] = X2Color::brightness($value, 0.05, true);
         $colors['lighter_' . $key] = X2Color::brightness($value, 0.1, true);
     }
     // generate smart text for module overrides
     foreach (array_filter($settings, function ($key) {
         return preg_match('/^background_.*_override$/', $key);
     }) as $key) {
         if (isset($colors[$key]) && $colors[$key]) {
             $colors[preg_replace('/^background_/', 'smart_text_', $key)] = X2Color::smartText($colors[$key], $colors['text'] ? '' : '#000000');
         } else {
             $colors[preg_replace('/^background_/', 'smart_text_', $key)] = '';
         }
     }
     # settings for most borders in the app
     $colors['border'] = $colors['lighter_content'];
     # Smart text for highlight 1 (Buttons and Windows)
     if (isset($colors['highlight1'], $colors['text']) && !empty($colors['highlight1']) && !empty($colors['text'])) {
         $colors['smart_text'] = X2Color::smartText($colors['highlight1'], $colors['text']);
     }
     # Smart text for highlight 2 (highlighted buttons)
     if (isset($colors['highlight2'], $colors['text']) && !empty($colors['highlight2']) && !empty($colors['text'])) {
         $colors['smart_text2'] = X2Color::smartText($colors['highlight2'], $colors['text']);
     }
     Yii::app()->cache->set(self::getCacheKey(), $colors, 0);
     return $colors;
 }
Ejemplo n.º 8
0
 /**
  * Populates the array with different color option
  * @return array array filled with formatted css color strings
  */
 public static function generatePalette($preferences)
 {
     $colors = $preferences;
     // Flag to indicate this array is generated
     $colors['generated'] = true;
     //Keys for smart text
     $colors['smart_text'] = '';
     $colors['smart_text2'] = '';
     if (isset($colors['backgroundImg']) && $colors['backgroundImg']) {
         $colors['background'] = '';
     }
     foreach (self::$settingsList as $key) {
         $value = isset($colors[$key]) ? $colors[$key] : '';
         if (!preg_match("/#/", $value) && $value) {
             $colors[$key] = '#' . $value;
         }
         $colors['darker_' . $key] = X2Color::brightness($value, -0.1, false);
         $colors['dark_' . $key] = X2Color::brightness($value, -0.05, false);
         $colors['brighter_' . $key] = X2Color::brightness($value, 0.1, false);
         $colors['bright_' . $key] = X2Color::brightness($value, 0.05, false);
         $colors['lighter_' . $key] = X2Color::brightness($value, 0.1, true);
         $colors['light_' . $key] = X2Color::brightness($value, 0.05, true);
         $colors['opaque_' . $key] = X2Color::opaque($value, 0.2);
     }
     # settings for most borders in the app
     $colors['border'] = $colors['lighter_content'];
     # Smart text for highlight 1 (Buttons and Windows)
     if (isset($colors['highlight1'], $colors['text']) && !empty($colors['highlight1']) && !empty($colors['text'])) {
         $colors['smart_text'] = X2Color::smartText($colors['highlight1'], $colors['text']);
     }
     # Smart text for highlight 2 (highlighted buttons)
     if (isset($colors['highlight2'], $colors['text']) && !empty($colors['highlight2']) && !empty($colors['text'])) {
         $colors['smart_text2'] = X2Color::smartText($colors['highlight2'], $colors['text']);
     }
     return $colors;
 }
Ejemplo n.º 9
0
 /**
  * @param type $fieldName
  * @param type $htmlOptions
  */
 public function renderInput($fieldName, $htmlOptions = array())
 {
     if ($fieldName === 'color') {
         $field = $this->getField($fieldName);
         $options = Dropdowns::getItems($field->linkType, null, false);
         $enableDropdownLegend = Yii::app()->settings->enableColorDropdownLegend;
         if ($enableDropdownLegend) {
             $htmlOptions['options'] = array();
             foreach ($options as $value => $label) {
                 $brightness = X2Color::getColorBrightness($value);
                 $fontColor = $brightness > 127.5 ? 'black' : 'white';
                 $htmlOptions['options'][$value] = array('style' => 'background-color: ' . $value . ';
                          color: ' . $fontColor);
             }
         }
         return CHtml::activeDropDownList($this, $field->fieldName, $options, $htmlOptions);
     } elseif ($fieldName == 'priority') {
         return CHtml::activeDropdownList($this, 'priority', self::getPriorityLabels());
     }
     return parent::renderInput($fieldName, $htmlOptions);
 }