Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F803981
D17.id26.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Feb 26, 9:02 AM
Size
13 KB
Mime Type
text/x-diff
Expires
Thu, Feb 27, 9:02 AM (7 h, 50 m)
Engine
blob
Format
Raw Data
Handle
576701
Attached To
D17: INP-1388 - Make CKEditor stylesheet within theme editable
D17.id26.diff
View Options
Index: core/admin_templates/themes/themes_edit.tpl
===================================================================
--- core/admin_templates/themes/themes_edit.tpl
+++ core/admin_templates/themes/themes_edit.tpl
@@ -61,6 +61,8 @@
<inp2:m_RenderElement name="inp_edit_textarea" prefix="theme" field="Description" title="la_fld_Description" cols="25" rows="3"/>
<inp2:m_RenderElement name="inp_edit_checkbox" prefix="theme" field="Enabled" title="la_fld_Enabled"/>
<inp2:m_RenderElement name="inp_edit_box" prefix="theme" field="CacheTimeout" title="la_prompt_lang_cache_timeout"/>
+ <inp2:m_RenderElement name="inp_edit_box" prefix="theme" field="StylesheetFile"/>
+
<!--##
<inp2:m_if check="m_ModuleEnabled" module="In-Portal">
<inp2:m_RenderElement name="inp_edit_options" prefix="theme" field="StylesheetId" title="la_prompt_Stylesheet" has_empty="1"/>
@@ -70,4 +72,4 @@
<inp2:m_RenderElement name="inp_edit_filler"/>
</table>
</div>
-<inp2:m_include t="incs/footer"/>
\ No newline at end of file
+<inp2:m_include t="incs/footer"/>
Index: core/install/english.lang
===================================================================
--- core/install/english.lang
+++ core/install/english.lang
@@ -265,6 +265,7 @@
<PHRASE Label="la_error_copy_subcategory" Module="Core" Type="1">RXJyb3IgY29weWluZyBzdWJzZWN0aW9ucw==</PHRASE>
<PHRASE Label="la_error_CustomExists" Module="Core" Type="1">Q3VzdG9tIGZpZWxkIHdpdGggaWRlbnRpY2FsIG5hbWUgYWxyZWFkeSBleGlzdHM=</PHRASE>
<PHRASE Label="la_error_EmailTemplateBodyMissing" Module="Core" Type="1">RW1haWwgRGVzaWduIFRlbXBsYXRlIHNob3VsZCBjb250YWluIGF0IGxlYXN0ICIkYm9keSIgdGFnIGluIGl0Lg==</PHRASE>
+ <PHRASE Label="la_error_FileNotFound" Module="Core" Type="1">RmlsZSBub3QgZm91bmQ=</PHRASE>
<PHRASE Label="la_error_FileTooLarge" Module="Core" Type="1">RmlsZSBpcyB0b28gbGFyZ2U=</PHRASE>
<PHRASE Label="la_error_GroupNotFound" Module="Core" Type="1">Z3JvdXAgbm90IGZvdW5k</PHRASE>
<PHRASE Label="la_error_InvalidFieldName" Module="Core" Type="1">RmllbGQgZG9lc24ndCBleGlzdCBpbiAiJXMiIHVuaXQgY29uZmln</PHRASE>
@@ -669,6 +670,7 @@
<PHRASE Label="la_fld_Status" Module="Core" Type="1" Column="U3RhdHVz">U3RhdHVz</PHRASE>
<PHRASE Label="la_fld_Sticky" Module="Core" Type="1" Column="U3RpY2t5">U3RpY2t5</PHRASE>
<PHRASE Label="la_fld_StopWord" Module="Core" Type="1" Column="U3RvcCBXb3Jk">U3RvcCBXb3Jk</PHRASE>
+ <PHRASE Label="la_fld_StylesheetFile" Module="Core" Type="1" Hint="UmVsYXRpdmUgcGF0aCB0byBzdHlsZXNoZWV0IGZpbGUgd2l0aGluIHRoZW1lIChlLmcuICJpbmMvc3R5bGUuY3NzIiku" Column="U3R5bGVzaGVldCBGaWxl">U3R5bGVzaGVldCBGaWxl</PHRASE>
<PHRASE Label="la_fld_Subject" Module="Core" Type="1" Column="U3ViamVjdA==">U3ViamVjdA==</PHRASE>
<PHRASE Label="la_fld_SubmissionTime" Module="Core" Type="1">U3VibWl0dGVkIE9u</PHRASE>
<PHRASE Label="la_fld_SubmitNotifyEmail" Module="Core" Type="1" Hint="RW1haWwgYWRkcmVzcyB3aGVyZSBub3RpZmljYXRpb24gYWJvdXQgbmV3IHN1Ym1pc3Npb25zIHdpbGwgYmUgc2VuZCB0by4gRGVmYXVsdCBlbWFpbCBhZGRyZXNzIHdpbGwgYmUgdXNlZCBpZiB0aGlzIGZpZWxkIGlzIGxlZnQgYmxhbmsu" Column="U3VibWlzc2lvbiBOb3RpZmljYXRpb24gRW1haWw=">U3VibWlzc2lvbiBOb3RpZmljYXRpb24gRW1haWw=</PHRASE>
Index: core/install/install_schema.sql
===================================================================
--- core/install/install_schema.sql
+++ core/install/install_schema.sql
@@ -352,6 +352,7 @@
StylesheetId int(10) unsigned NOT NULL DEFAULT '0',
LanguagePackInstalled tinyint(3) unsigned NOT NULL DEFAULT '0',
TemplateAliases text,
+ StylesheetFile varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (ThemeId),
KEY Enabled (Enabled),
KEY StylesheetId (StylesheetId),
@@ -1422,4 +1423,4 @@
TransitionEffect varchar(255) NOT NULL DEFAULT '',
TransitionEffectCustom varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (PromoBlockGroupId)
-);
\ No newline at end of file
+);
Index: core/install/upgrades.sql
===================================================================
--- core/install/upgrades.sql
+++ core/install/upgrades.sql
@@ -2922,3 +2922,6 @@
UPDATE LanguageLabels
SET l1_Translation = 'Field value length is out of range, possible value length from {min_length} to {max_length}'
WHERE PhraseKey = 'LA_ERR_LENGTH_OUT_OF_RANGE';
+
+ALTER TABLE Themes ADD StylesheetFile VARCHAR( 255 ) NOT NULL DEFAULT '';
+UPDATE Themes SET StylesheetFile = 'platform/inc/styles.css' WHERE `Name` = 'advanced';
Index: core/kernel/db/db_tag_processor.php
===================================================================
--- core/kernel/db/db_tag_processor.php
+++ core/kernel/db/db_tag_processor.php
@@ -2534,9 +2534,13 @@
$value = $this->Field($params);
$name = array_key_exists('name', $params) ? $params['name'] : $this->InputName($params);
- $theme_path = $this->Application->GetFrontThemePath() . '/inc';
+ /** @var ThemeItem $theme */
+ $theme = $this->Application->recallObject('theme.current');
+ $stylesheet_file = $theme->getStylesheetFile(true);
- if ( file_exists(FULL_PATH . $theme_path . '/style.css') ) {
+ if ( $stylesheet_file ) {
+ $stylesheet_folder_url = dirname($stylesheet_file) . '/';
+
$url_params = Array (
'events[fck]' => 'OnGetsEditorStyles',
'no_pass_through' => 1, 'pass' => 'm', 'no_amp' => 1
@@ -2545,11 +2549,11 @@
$styles_css = $this->Application->HREF('index', '_FRONT_END_', $url_params, 'index.php');
}
else {
- $theme_path = rtrim(EDITOR_PATH, '/');
- $styles_css = $this->Application->BaseURL($theme_path) . 'style.css';
+ $stylesheet_folder_url = $this->Application->BaseURL(rtrim(EDITOR_PATH, '/'));
+ $styles_css = $stylesheet_folder_url . 'style.css';
}
- $styles_js = $this->Application->BaseURL($theme_path) . 'styles.js';
+ $styles_js = $stylesheet_folder_url . 'styles.js';
/*$page_id = $this->Application->GetVar('c_id');
$content_id = $this->Application->GetVar('content_id');
@@ -3156,4 +3160,4 @@
return '';
}
-}
\ No newline at end of file
+}
Index: core/units/fck/fck_eh.php
===================================================================
--- core/units/fck/fck_eh.php
+++ core/units/fck/fck_eh.php
@@ -243,12 +243,15 @@
*/
function OnGetsEditorStyles($event)
{
+ /** @var ThemeItem $theme */
+ $theme = $this->Application->recallObject('theme.current');
+
+ /** @var MinifyHelper $minify_helper */
$minify_helper = $this->Application->recallObject('MinifyHelper');
- /* @var $minify_helper MinifyHelper */
$this->Application->InitParser();
- $styles_css = $minify_helper->CompressScriptTag( Array ('files' => 'inc/style.css') );
+ $styles_css = $minify_helper->CompressScriptTag(array('files' => $theme->getStylesheetFile(true)));
$event->redirect = 'external:' . $styles_css;
}
- }
\ No newline at end of file
+ }
Index: core/units/helpers/themes_helper.php
===================================================================
--- core/units/helpers/themes_helper.php
+++ core/units/helpers/themes_helper.php
@@ -75,6 +75,8 @@
}
$this->themeFiles = Array ();
+ $theme_path = $this->themesFolder . '/' . $theme_name;
+
if ($theme_id) {
if (!$theme_enabled) {
// don't process existing theme files, that are disabled
@@ -95,6 +97,8 @@
}
else {
// theme was not found in db, but found on hdd -> create new
+ $config = $this->getConfiguration($theme_path);
+
$theme_info = Array (
'Name' => $theme_name,
'Enabled' => 0,
@@ -102,7 +106,8 @@
'PrimaryTheme' => 0,
'CacheTimeout' => 3600, // not in use right now
'StylesheetId' => 0, // not in use right now
- 'LanguagePackInstalled' => 0
+ 'LanguagePackInstalled' => 0,
+ 'StylesheetFile' => isset($config['stylesheet_file']) ? $config['stylesheet_file'] : '',
);
$this->Conn->doInsert($theme_info, $table_name);
@@ -115,7 +120,6 @@
}
$this->_themeNames[$theme_id] = $theme_name;
- $theme_path = $this->themesFolder.'/'.$theme_name;
$this->FindThemeFiles('', $theme_path, $theme_id); // search from base theme directory
// delete file records from db, that were not found on hdd
@@ -230,6 +234,37 @@
}
return $template_aliases;
+ }
+
+ /**
+ * Returns theme configuration.
+ *
+ * @param string $theme_path Absolute path to theme.
+ *
+ * @return array
+ */
+ protected function getConfiguration($theme_path)
+ {
+ $xml_file = $theme_path . '/_install/theme.xml';
+
+ if ( !file_exists($xml_file) ) {
+ return array();
+ }
+
+ $theme = simplexml_load_file($xml_file);
+
+ if ( $theme === false ) {
+ // broken xml OR no aliases defined
+ return array();
+ }
+
+ $ret = array();
+
+ foreach ( $theme->attributes() as $name => $value ) {
+ $ret[(string)$name] = (string)$value;
+ }
+
+ return $ret;
}
/**
@@ -616,4 +651,4 @@
return $this->Conn->GetOne($sql);
}
- }
\ No newline at end of file
+ }
Index: core/units/themes/theme_item.php
===================================================================
--- core/units/themes/theme_item.php
+++ core/units/themes/theme_item.php
@@ -56,4 +56,32 @@
return $res;
}
+
+ /**
+ * Returns full path to stylesheet file.
+ *
+ * @param boolean $as_url Allows to return url to stylesheet file instead of it's path.
+ *
+ * @return string|boolean
+ */
+ public function getStylesheetFile($as_url = false)
+ {
+ $stylesheet_file = ltrim($this->GetDBField('StylesheetFile') ?: 'inc/style.css', '/');
+
+ $theme_path = FULL_PATH . '/themes/' . $this->GetDBField('Name');
+ $stylesheet_file = $theme_path . '/' . $stylesheet_file;
+
+ if ( !file_exists($stylesheet_file) ) {
+ return false;
+ }
+
+ if ( $as_url ) {
+ /** @var FileHelper $file_helper */
+ $file_helper = $this->Application->recallObject('FileHelper');
+
+ return $file_helper->pathToUrl($stylesheet_file);
+ }
+
+ return $stylesheet_file;
+ }
- }
\ No newline at end of file
+ }
Index: core/units/themes/themes_config.php
===================================================================
--- core/units/themes/themes_config.php
+++ core/units/themes/themes_config.php
@@ -129,7 +129,12 @@
'not_null' => 1, 'default' => 0
),
'TemplateAliases' => Array ('type' => 'string', 'formatter' => 'kSerializedFormatter', 'default' => 'a:0:{}'),
+ 'StylesheetFile' => array(
+ 'type' => 'string', 'max_len' => 255,
+ 'error_msgs' => array('not_found' => '!la_error_FileNotFound!'),
+ 'not_null' => 1, 'default' => ''
- ),
+ ),
+ ),
'Grids' => Array(
'Default' => Array(
@@ -147,7 +152,8 @@
'Enabled' => Array( 'title'=>'column:la_fld_Status', 'filter_block' => 'grid_options_filter', 'width' => 200, ),
// 'PrimaryTheme' => Array( 'title'=>'column:la_fld_Primary', 'filter_block' => 'grid_options_filter'),
'LanguagePackInstalled' => Array ('title' => 'la_col_LanguagePackInstalled', 'filter_block' => 'grid_options_filter', 'width' => 200,),
+ 'StylesheetFile' => array('filter_block' => 'grid_like_filter', 'width' => 150, 'hidden' => 1),
),
),
),
- );
\ No newline at end of file
+ );
Index: core/units/themes/themes_eh.php
===================================================================
--- core/units/themes/themes_eh.php
+++ core/units/themes/themes_eh.php
@@ -132,6 +132,25 @@
}
/**
+ * Validate entered stylesheet path.
+ *
+ * @param kEvent $event Event.
+ *
+ * @return void
+ */
+ protected function OnBeforeItemUpdate(kEvent $event)
+ {
+ parent::OnBeforeItemUpdate($event);
+
+ /** @var ThemeItem $object */
+ $object = $event->getObject();
+
+ if ( $object->GetDBField('StylesheetFile') && !$object->getStylesheetFile() ) {
+ $object->SetError('StylesheetFile', 'not_found');
+ }
+ }
+
+ /**
* Set's primary theme (when checkbox used on editing form)
*
* @param kEvent $event
Index: themes/advanced/_install/theme.xml
===================================================================
--- themes/advanced/_install/theme.xml
+++ themes/advanced/_install/theme.xml
@@ -1,5 +1,5 @@
-<theme>
+<theme stylesheet_file="platform/inc/styles.css">
<default_design>platform/designs/general</default_design>
<form_design>platform/designs/form</form_design>
<form_thankyou>platform/thankyou</form_thankyou>
-</theme>
\ No newline at end of file
+</theme>
Index: themes/advanced/platform/inc/styles.js
===================================================================
--- themes/advanced/platform/inc/styles.js
+++ themes/advanced/platform/inc/styles.js
@@ -0,0 +1,48 @@
+// The set of styles for the Styles combo
+CKEDITOR.stylesSet.add(
+ 'portal',
+ [
+ // Block Styles
+ { name : 'Alex Blue Title' , element : 'h3', styles : { 'color' : 'Blue' } },
+ { name : 'Red Title' , element : 'h3', styles : { 'color' : 'Red' } },
+
+ // Inline Styles
+ { name : 'Marker: Yellow' , element : 'span', styles : { 'background-color' : 'Yellow' } },
+ { name : 'Marker: Green' , element : 'span', styles : { 'background-color' : 'Lime' } },
+
+ { name : 'Big' , element : 'big' },
+ { name : 'Small' , element : 'small' },
+ { name : 'Typewriter' , element : 'tt' },
+ { name : 'Computer Code' , element : 'code' },
+ { name : 'Keyboard Phrase' , element : 'kbd' },
+ { name : 'Sample Text' , element : 'samp' },
+ { name : 'Variable' , element : 'var' },
+ { name : 'Deleted Text' , element : 'del' },
+ { name : 'Inserted Text' , element : 'ins' },
+ { name : 'Cited Work' , element : 'cite' },
+ { name : 'Inline Quotation' , element : 'q' },
+
+ // Object Styles
+ {
+ name : 'Image on Left',
+ element : 'img',
+ attributes :
+ {
+ 'style' : 'padding: 5px; margin-right: 5px',
+ 'border' : '2',
+ 'align' : 'left'
+ }
+ },
+
+ {
+ name : 'Image on Right',
+ element : 'img',
+ attributes :
+ {
+ 'style' : 'padding: 5px; margin-right: 5px',
+ 'border' : '2',
+ 'align' : 'right'
+ }
+ }
+ ]
+);
Event Timeline
Log In to Comment