public function testGeneratePalette2() { $profileDefaultThemeLegacy = $this->profiles('adminProfile'); $profileNoTheme = $this->profiles('testProfile'); $profileSelectedThemeLegacy = $this->profiles('testProfile2'); // ensure that keys get normalized $this->assertTrue(array_keys(ThemeGenerator::generatePalette($profileDefaultThemeLegacy->theme, true)) === array_keys(ThemeGenerator::generatePalette($profileNoTheme->theme, true)) && array_keys(ThemeGenerator::generatePalette($profileNoTheme->theme, true)) === array_keys(ThemeGenerator::generatePalette($profileSelectedThemeLegacy->theme, true))); }
/** * 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); }
public function testGeneratePalette($colors = null) { // Test for malformed array input if (!$colors) { $colors = $this->normalColors; } $generated = ThemeGenerator::generatePalette($colors); VERBOSE_MODE && print_r($generated); $keys = ThemeGenerator::getProfileKeys(); $this->assertTrue(in_array('themeName', $keys)); VERBOSE_MODE && print_r($keys); foreach ($keys as $key) { if ($key == 'themeName') { continue; } $this->assertArrayHasKey($key, $generated); } $this->assertCount(count($keys) - 1, $generated); }
/** * @param $file string pathname of a css file * @param $lineNumber int lineNumber of the theme tag * @return array of needed items to construct the array seen in {@link scanCssFile}. */ public function makeRule($file, $lineNumber) { $lines = file($file); $themeLine = $lines[$lineNumber]; // print_r($themeLine);/ $stripped = preg_replace('/.*@theme\\ *(.*)\\*\\//', '\\1', $themeLine); // Remove extra spaces in between $stripped = preg_replace('/\\ \\ */', ' ', $stripped); $stripped = preg_replace('/:/', '', $stripped); $params = explode(' ', $stripped); // Backtrack the last comment while (!preg_match('/line\\ [0-9]+/', $lines[$lineNumber])) { $lineNumber--; if ($lineNumber < 0) { throw new Exception("Backtracked and found no comment in {$file}", 1); } } $comment = $lines[$lineNumber]; $selector = ''; // Move forward lines and append the selector on each line while (!preg_match('/{/', $lines[$lineNumber])) { $lineNumber++; $selector .= $lines[$lineNumber]; } // tab indent to look nice $selector = preg_replace('/\\n[^$]/', "\n ", $selector); $rule = $params[0]; $value = $params[1]; // Throw exception if it is not a valid key if (!in_array($value, ThemeGenerator::getProfileKeys())) { $comment = preg_replace('/\\/\\*(.*)\\*\\//', '\\1', $comment); throw new Exception("\nTheme Key '{$value}' is not a valid key.\nFound at{$comment}"); } return array($selector, $comment, array('rule' => $rule, 'value' => $value)); }
* Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * X2Engine" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by X2Engine". *****************************************************************************************/ Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/about-page.css'); $this->layout = '//layouts/column1'; $this->pageTitle = Yii::app()->settings->appName . ' - ' . Yii::t('app', 'About'); $logo = Yii::app()->baseUrl . '/images/x2engine.png'; ?> <div id='icon-container'> <?php if (ThemeGenerator::isThemed()) { echo X2Html::logo('about', array('id' => 'x2-about-logo')); } else { echo CHtml::image($logo, ''); } ?> </div> <?php Yii::app()->clientScript->registerScript('loadJqueryVersion', "\$('#jqueryVersion').html(\$().jquery);", CClientScript::POS_READY); ?> <div class='center-column-container form left' > <b><?php echo Yii::t('app', 'Version') . " " . Yii::app()->params->version; ?> </b><br>
public function behaviors() { // Skip loading theme settins if this request isn't associated with a session, eg API $theme = Yii::app()->params->noSession ? array() : ThemeGenerator::getProfileKeys(); return array('X2LinkableBehavior' => array('class' => 'X2LinkableBehavior', 'baseRoute' => '/profile', 'autoCompleteSource' => null, 'module' => 'profile'), 'ERememberFiltersBehavior' => array('class' => 'application.components.ERememberFiltersBehavior', 'defaults' => array(), 'defaultStickOnClear' => false), 'NormalizedJSONFieldsBehavior' => array('class' => 'application.components.NormalizedJSONFieldsBehavior', 'transformAttributes' => array('theme' => array_merge($theme, array('backgroundColor', 'menuBgColor', 'menuTextColor', 'pageHeaderBgColor', 'pageHeaderTextColor', 'activityFeedWidgetBgColor', 'activityFeedWidgetTextColor', 'backgroundImg', 'backgroundTiling', 'pageOpacity', 'themeName', 'private', 'owner', 'loginSound', 'notificationSound', 'gridViewRowColorOdd', 'gridViewRowColorEven')))), 'JSONFieldsDefaultValuesBehavior' => array('class' => 'application.components.JSONFieldsDefaultValuesBehavior', 'transformAttributes' => array('miscLayoutSettings' => array('themeSectionExpanded' => true, 'unhideTagsSectionExpanded' => true, 'x2flowShowLabels' => true, 'profileInfoIsMinimized' => false, 'perStageWorkflowView' => true, 'columnWidth' => 50, 'recordViewColumnWidth' => 65, 'enableTransactionalView' => true, 'enableJournalView' => true, 'viewModeActionSubmenuOpen' => true)), 'maintainCurrentFieldsOrder' => true), 'X2SmartSearchModelBehavior' => array('class' => 'application.components.X2SmartSearchModelBehavior')); }
public function behaviors() { Yii::import('application.components.X2ActiveRecordBehavior'); Yii::import('application.components.behaviors.FileFieldBehavior'); // Skip loading theme settins if this request isn't associated with a session, eg API $theme = Yii::app()->params->noSession ? array() : ThemeGenerator::getProfileKeys(true, true, false); $that = $this; return array('X2StaticFieldsBehavior' => array('class' => 'application.components.behaviors.X2StaticFieldsBehavior', 'translationCategory' => 'profile', 'fields' => array(array('fieldName' => 'fullName', 'attributeLabel' => 'Full Name', 'type' => 'varchar'), array('fieldName' => 'tagLine', 'attributeLabel' => 'Tag Line', 'type' => 'varchar'), array('fieldName' => 'username', 'attributeLabel' => 'Username', 'type' => 'varchar'), array('fieldName' => 'officePhone', 'attributeLabel' => 'Office Phone', 'type' => 'phone'), array('fieldName' => 'cellPhone', 'attributeLabel' => 'Cell Phone', 'type' => 'phone'), array('fieldName' => 'emailAddress', 'attributeLabel' => 'Email Address', 'type' => 'email'), array('fieldName' => 'language', 'attributeLabel' => 'Language', 'type' => 'dropdown', 'includeEmpty' => false, 'linkType' => function () use($that) { return $that->getLanguageOptions(); }), array('fieldName' => 'googleId', 'attributeLabel' => 'Google ID', 'type' => 'email'))), 'FileFieldBehavior' => array('class' => 'application.components.behaviors.FileFieldBehavior', 'attribute' => 'avatar', 'fileAttribute' => 'photo', 'fileType' => FileFieldBehavior::IMAGE, 'getFilename' => function (CUploadedFile $file) { $time = time(); $rand = chr(rand(65, 90)); $salt = $time . $rand; $name = md5($salt . md5($salt) . $salt); return 'uploads/protected/' . $name . '.' . $file->getExtensionName(); }), 'X2LinkableBehavior' => array('class' => 'X2LinkableBehavior', 'baseRoute' => '/profile', 'autoCompleteSource' => null, 'module' => 'profile'), 'ERememberFiltersBehavior' => array('class' => 'application.components.ERememberFiltersBehavior', 'defaults' => array(), 'defaultStickOnClear' => false), 'NormalizedJSONFieldsBehavior' => array('class' => 'application.components.NormalizedJSONFieldsBehavior', 'transformAttributes' => array('theme' => array_merge($theme, array('backgroundColor', 'menuBgColor', 'menuTextColor', 'pageHeaderBgColor', 'pageHeaderTextColor', 'activityFeedWidgetBgColor', 'activityFeedWidgetTextColor', 'backgroundImg', 'backgroundTiling', 'pageOpacity', 'themeName', 'private', 'owner', 'loginSound', 'notificationSound', 'gridViewRowColorOdd', 'gridViewRowColorEven', 'enableLoginBgImage')))), 'JSONFieldsDefaultValuesBehavior' => array('class' => 'application.components.JSONFieldsDefaultValuesBehavior', 'transformAttributes' => array('miscLayoutSettings' => array('themeSectionExpanded' => true, 'unhideTagsSectionExpanded' => true, 'x2flowShowLabels' => true, 'profileInfoIsMinimized' => false, 'perStageWorkflowView' => true, 'columnWidth' => 50, 'recordViewColumnWidth' => 65, 'enableTransactionalView' => false, 'enableJournalView' => true, 'viewModeActionSubmenuOpen' => true)), 'maintainCurrentFieldsOrder' => true), 'X2SmartSearchModelBehavior' => array('class' => 'application.components.X2SmartSearchModelBehavior')); }
/** * Display/set user profile settings. */ public function actionSettings() { $model = $this->loadModel(Yii::app()->user->getId()); if (isset($_POST['Profile']) || isset($_POST['preferences'])) { if (isset($_POST['Profile'])) { $model->attributes = $_POST['Profile']; if ($model->save()) { //$this->redirect(array('view','id'=>$model->id)); } } if (isset($_POST['preferences'])) { $model->theme = ThemeGenerator::generatePalette($_POST['preferences']); if ($model->save()) { Yii::import('application.components.ThemeGenerator.LoginThemeHelper'); LoginThemeHelper::saveProfileTheme($_POST['preferences']['themeName']); } } $this->refresh(); } $modules = Modules::model()->findAllByAttributes(array('visible' => 1)); $menuItems = array(); foreach ($modules as $module) { if ($module->name == 'document') { $menuItems[$module->title] = $module->title; } else { $menuItems[$module->name] = Yii::t('app', $module->title); } } $menuItems = array('' => Yii::t('app', 'Activity Feed')) + $menuItems; $languageDirs = scandir('./protected/messages'); // scan for installed language folders $languages = array('en' => 'English'); foreach ($languageDirs as $code) { // look for langauges name $name = $this->getLanguageName($code, $languageDirs); // in each item in $languageDirs if ($name !== false) { $languages[$code] = $name; } // add to $languages if name is found } $times = $this->getTimeZones(); $myThemeProvider = new CActiveDataProvider('Media', array('criteria' => array('condition' => "((private = 1 AND uploadedBy = '" . Yii::app()->user->name . "') OR private = 0) AND associationType = 'theme'", 'order' => 'createDate DESC'), 'pagination' => false)); $myBackgroundProvider = new CActiveDataProvider('Media', array('criteria' => array('condition' => "(associationType = 'bg-private' AND associationId = '" . Yii::app()->user->getId() . "') OR associationType = 'bg'", 'order' => 'createDate DESC'), 'pagination' => false)); $myLoginSoundProvider = new CActiveDataProvider('Media', array('criteria' => array('condition' => "(associationType='loginSound' AND (private=0 OR private IS NULL OR uploadedBy='" . Yii::app()->user->getName() . "'))", 'order' => 'createDate DESC'), 'pagination' => false)); $myNotificationSoundProvider = new CActiveDataProvider('Media', array('criteria' => array('condition' => "(associationType='notificationSound' AND (private=0 OR private IS NULL OR uploadedBy='" . Yii::app()->user->getName() . "'))", 'order' => 'createDate DESC'), 'pagination' => false)); $hiddenTags = json_decode(Yii::app()->params->profile->hiddenTags, true); if (empty($hiddenTags)) { $hiddenTags = array(); } if (sizeof($hiddenTags)) { $tagParams = AuxLib::bindArray($hiddenTags); $allTags = Yii::app()->db->createCommand()->select('COUNT(*) AS count, tag')->from('x2_tags')->group('tag')->where('tag IS NOT NULL AND tag IN (' . implode(',', array_keys($tagParams)) . ')', $tagParams)->order('tag ASC')->limit(20)->queryAll(); } else { $allTags = array(); } $admin = Yii::app()->settings; $this->render('settings', array('model' => $model, 'languages' => $languages, 'times' => $times, 'myThemes' => $myThemeProvider, 'myBackgrounds' => $myBackgroundProvider, 'myLoginSounds' => $myLoginSoundProvider, 'myNotificationSounds' => $myNotificationSoundProvider, 'menuItems' => $menuItems, 'allTags' => $allTags)); }
/** * Display/set user profile settings. */ public function actionSettings() { $model = $this->loadModel(Yii::app()->user->getId()); if (isset($_POST['Profile']) || isset($_POST['preferences'])) { if (isset($_POST['Profile'])) { $model->attributes = $_POST['Profile']; if (isset($_POST['preferences']['loginSound'])) { $pieces = explode(',', $_POST['preferences']['loginSound']); $model->loginSound = $pieces[0]; unset($_POST['preferences']['loginSound']); } if (isset($_POST['preferences']['notificationSound'])) { $pieces = explode(',', $_POST['preferences']['notificationSound']); $model->notificationSound = $pieces[0]; unset($_POST['preferences']['notificationSound']); } $model->save(); } if (isset($_POST['preferences']['themeName'])) { ThemeGenerator::clearCache(); Yii::import('application.components.ThemeGenerator.LoginThemeHelper'); LoginThemeHelper::saveProfileTheme($_POST['preferences']['themeName']); $model->theme = array_merge(array_diff_key($model->theme, array_flip(ThemeGenerator::getProfileKeys())), ThemeGenerator::loadDefault($_POST['preferences']['themeName'], false), array_diff_key($_POST['preferences'], array_flip(ThemeGenerator::getProfileKeys()))); $model->save(); } $this->refresh(); } $modules = Modules::model()->findAllByAttributes(array('visible' => 1)); $menuItems = array(); foreach ($modules as $module) { if ($module->name == 'document') { $menuItems[$module->title] = $module->title; } else { $menuItems[$module->name] = Yii::t('app', $module->title); } } $menuItems = array('' => Yii::t('app', 'Activity Feed')) + $menuItems; $languages = $model->getLanguageOptions(); $times = $this->getTimeZones(); $myThemeProvider = new CActiveDataProvider('Media', array('criteria' => array('condition' => "((private = 1 AND uploadedBy = '" . Yii::app()->user->name . "') OR private = 0) AND associationType = 'theme'", 'order' => 'createDate DESC'), 'pagination' => false)); $myBackgroundProvider = new CActiveDataProvider('Media', array('criteria' => array('condition' => "(associationType = 'bg-private' AND associationId = '" . Yii::app()->user->getId() . "') OR associationType = 'bg'", 'order' => 'createDate DESC'), 'pagination' => false)); $myLoginSoundProvider = new CActiveDataProvider('Media', array('criteria' => array('condition' => "(associationType='loginSound' AND (private=0 OR private IS NULL OR uploadedBy='" . Yii::app()->user->getName() . "'))", 'order' => 'createDate DESC'), 'pagination' => false)); $myNotificationSoundProvider = new CActiveDataProvider('Media', array('criteria' => array('condition' => "(associationType='notificationSound' AND (private=0 OR private IS NULL OR uploadedBy='" . Yii::app()->user->getName() . "'))", 'order' => 'createDate DESC'), 'pagination' => false)); $hiddenTags = json_decode(Yii::app()->params->profile->hiddenTags, true); if (empty($hiddenTags)) { $hiddenTags = array(); } if (sizeof($hiddenTags)) { $tagParams = AuxLib::bindArray($hiddenTags); $allTags = Yii::app()->db->createCommand()->select('COUNT(*) AS count, tag')->from('x2_tags')->group('tag')->where('tag IS NOT NULL AND tag IN (' . implode(',', array_keys($tagParams)) . ')', $tagParams)->order('tag ASC')->limit(20)->queryAll(); } else { $allTags = array(); } $admin = Yii::app()->settings; $this->render('settings', array('model' => $model, 'languages' => $languages, 'times' => $times, 'myThemes' => $myThemeProvider, 'myBackgrounds' => $myBackgroundProvider, 'myLoginSounds' => $myLoginSoundProvider, 'myNotificationSounds' => $myNotificationSoundProvider, 'menuItems' => $menuItems, 'allTags' => $allTags)); }
* these Appropriate Legal Notices must retain the display of the "Powered by * X2Engine" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by X2Engine". *****************************************************************************************/ /** * This page renders the theme selector and the appropriate javascript */ Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl . '/themes/x2engine/css/profile/themeSelector.css'); Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/js/ThemeSelector.js', CClientScript::POS_END); $user = Yii::app()->user->name; $params = CJSON::encode(array('defaults' => array(ThemeGenerator::$defaultLight, ThemeGenerator::$defaultDark), 'active' => $selected, 'user' => $user, 'isAdmin' => Yii::app()->params->isAdmin ? 1 : 0, 'translations' => array('createNew' => Yii::t('profile', 'Create a new theme to edit')))); Yii::app()->clientScript->registerScript('schemeJS', "\n\n\n\$(function () {\n new x2.ThemeSelector({$params});\n});\n\n", CClientScript::POS_END); echo "<input type='hidden' name='regenerate-theme' value='1'>"; echo "<div class='theme-picker' id='theme-picker'>"; $settings = ThemeGenerator::getSettingsList(); $themes = $myThemes->data; foreach ($themes as $theme) { $scheme = CJSON::decode($theme->description); if (!is_array($scheme)) { continue; } $fileName = $theme->fileName; $uploadedBy = $theme->uploadedBy; echo CHtml::openTag('div', array('class' => "scheme-container", 'name' => $fileName, 'data-id' => $theme->id)); echo CHtml::openTag('div', array('class' => 'scheme-container-inner', 'style' => "\n\t\t\t\tbackground: #{$scheme['content']};\n\t\t\t\tcolor: #{$scheme['text']};")); echo "<div id='name' > {$fileName} </div> "; if ($fileName == ThemeGenerator::$defaultLight || $fileName == ThemeGenerator::$defaultDark) { $uploadedByName = ''; } else { $uploadedByName = $uploadedBy;
echo Yii::t('profile', 'Delete'); ?> </button> <?php ?> <div style="clear:both"></div> <?php $this->renderPartial('_themeSettings', array('myThemes' => $myThemes, 'selected' => $preferences['themeName'])); ?> </div> <?php ThemeGenerator::renderThemeColorSelector('', '', '', array('id' => 'theme-color-selector-template', 'style' => 'display: none;'), true); ThemeGenerator::renderSettings(); ?> <div id='module-theme-override' <?php echo $preferences['themeName'] === 'Default' || !$preferences['themeName'] ? 'style="display: none;"' : ''; ?> > <?php echo Modules::dropDownList('', '', array('class' => 'x2-select')); ?> <button id='add-module-override-button' class='x2-button x2-small-button'> <?php echo CHtml::encode(Yii::t('app', 'Add Module Color')); ?> </button> </div>
private static function getModuleOverrideKeys($flatten = false) { if (!isset(self::$_moduleOverrideKeys)) { $moduleNames = Modules::getModuleNames(); self::$_moduleOverrideKeys = array('base' => array_map(function ($name) { return 'background_' . $name . '_override'; }, $moduleNames)); self::$_moduleOverrideKeys['computed'] = array_merge(array_map(function ($name) { return 'smart_text_' . $name . '_override'; }, $moduleNames), array_map(function ($name) { return 'light_background_' . $name . '_override'; }, $moduleNames), array_map(function ($name) { return 'lighter_background_' . $name . '_override'; }, $moduleNames)); } $moduleOverrideKeys = self::$_moduleOverrideKeys; if ($flatten) { $flattened = array(); foreach ($moduleOverrideKeys as $type => $keys) { $flattened = array_merge($flattened, $keys); } return $flattened; } return $moduleOverrideKeys; }
/** * @param $file string pathname of a css file * @param $lineNumber int lineNumber of the theme tag * @return array of needed items to construct the array seen in {@link scanCssFile}. */ public function makeRule($file, $lineNumber) { $lines = file($file); $themeLine = $lines[$lineNumber]; // print_r($themeLine);/ $stripped = preg_replace('/.*@theme\\ *(.*)\\*\\//', '\\1', $themeLine); // Remove extra spaces in between $stripped = preg_replace('/\\ \\ */', ' ', $stripped); $stripped = preg_replace('/:/', '', $stripped); $params = split(' ', $stripped); while (!preg_match('/{/', $lines[$lineNumber])) { $lineNumber--; } $selector = $lines[$lineNumber]; $comment = $lines[$lineNumber - 1]; $rule = $params[0]; $value = $params[1]; // Throw exception if it is not a valid key if (!in_array($value, ThemeGenerator::getProfileKeys())) { $comment = preg_replace('/\\/\\*(.*)\\*\\//', '\\1', $comment); throw new Exception("\nTheme Key '{$value}' is not a valid key.\nFound at{$comment}"); } return array($selector, $comment, array('rule' => $rule, 'value' => $value)); }
/** * Loads a theme for the login page * @param string $themeName string of the theme to render */ public static function loadDefault($themeName) { //In case default light was deleted if ($themeName == self::$defaultLight) { return array('themeName' => self::$defaultLight); } $media = X2Model::model('Media')->findByAttributes(array('associationType' => 'theme', 'fileName' => $themeName, 'private' => 0)); if (!$media) { $media = X2Model::model('Media')->findByAttributes(array('associationType' => 'theme', 'fileName' => self::$defaultDark)); if (!$media) { return self::loadDefault(self::$defaultLight); } } $json = CJSON::decode($media->description); $colors = ThemeGenerator::generatePalette($json); return $colors; }
$cs->registerMain(); $preferences = null; if ($profile != null) { $preferences = $profile->getTheme(); } $logoMissing = false; $checkFiles = array('images/powered_by_x2engine.png' => 'b7374cbbd29cd63191f7e0b1dcd83c48'); foreach ($checkFiles as $key => $value) { if (!file_exists($key) || hash_file('md5', $key) !== $value) { $logoMissing = true; } } /********************************* * Generate that the theme! ********************************/ ThemeGenerator::render(); /* Retrieve flash messages and calculate the appropriate styles for flash messages if applicable */ $allFlashes = Yii::app()->user->getFlashes(); $adminFlashes = array(); $index = 0; foreach ($allFlashes as $key => $message) { if (strpos($key, 'admin') === 0) { $adminFlashes[$index] = $message; $index++; } } if ($n_flash = count($adminFlashes)) { $flashTotalHeight = 17; // See layout.css for details $themeCss = ' div#header {
* * You can contact X2Engine, Inc. P.O. Box 66752, Scotts Valley, * California 95067, USA. or at email address contact@x2engine.com. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * X2Engine" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by X2Engine". *****************************************************************************************/ Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/views/admin/index.css'); ThemeGenerator::removeBackdrop(); $admin =& Yii::app()->settings; $editionStart = function ($edition) { ob_start(); if (!Yii::app()->contEd($edition)) { echo '<div title="' . Yii::t('admin', 'This feature is only available in {edition}', array('{edition}' => 'X2CRM ' . Yii::app()->editionLabels[$edition])) . '" class="only-in-edition edition-' . $edition . '">'; } }; $editionEnd = function ($edition) { if (!Yii::app()->contEd($edition)) { echo '</div><!-- .only-in-edition.edition-' . $edition . ' -->'; } $section = ob_get_contents(); ob_end_clean(); echo $section; };
/** * Helper action upon login * expects a post of the theme and sets it to be the current theme ONLY if the current theme is not already set. */ public static function login() { if (!isset($_POST[self::LOGIN_THEME_COOKIE])) { return; } $themeName = $_POST[self::LOGIN_THEME_COOKIE]; $profile = X2Model::model('Profile')->findByPk(Yii::app()->user->id); if ($profile->theme['themeName'] == '' || $profile->theme['themeName'] == ThemeGenerator::$defaultLight) { $profile->theme = ThemeGenerator::loadDefault($themeName, false); $profile->save(); } }