Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1101327
in-portal
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
Sat, Aug 16, 2:59 PM
Size
16 KB
Mime Type
text/x-diff
Expires
Mon, Aug 18, 2:59 PM (17 h, 37 m)
Engine
blob
Format
Raw Data
Handle
713251
Attached To
rINP In-Portal
in-portal
View Options
Index: trunk/core/kernel/utility/formatters/upload_formatter.php
===================================================================
--- trunk/core/kernel/utility/formatters/upload_formatter.php (revision 8073)
+++ trunk/core/kernel/utility/formatters/upload_formatter.php (revision 8074)
@@ -1,178 +1,178 @@
<?php
class kUploadFormatter extends kFormatter
{
var $DestinationPath;
var $FullPath;
function kUploadFormatter()
{
if ($this->DestinationPath)
{
$this->FullPath = FULL_PATH.$this->DestinationPath;
}
parent::kBase();
}
//function Parse($value, $options, &$errors)
function Parse($value, $field_name, &$object)
{
$ret = '';
$options = $object->GetFieldOptions($field_name);
if(getArrayValue($options, 'upload_dir'))
{
$this->DestinationPath = $options['upload_dir'];
$this->FullPath = FULL_PATH.$this->DestinationPath;
}
if (getArrayValue($value, 'upload') && getArrayValue($value, 'error') == UPLOAD_ERR_NO_FILE) {
// file was not uploaded this time, but was uploaded before, then use previously uploaded file (from db)
return getArrayValue($value, 'upload');
}
if ( is_array($value) && $value['size'] )
{
if ( is_array($value) && $value['error'] === UPLOAD_ERR_OK )
{
if ( getArrayValue($options, 'allowed_types') && !in_array($value['type'], $options['allowed_types']) )
{
$object->FieldErrors[$field_name]['pseudo'] = 'bad_file_format';
}
elseif ( $value['size'] > ($options['max_size'] ? $options['max_size'] : MAX_UPLOAD_SIZE) )
{
$object->FieldErrors[$field_name]['pseudo'] = 'bad_file_size';
}
elseif ( !is_writable($this->FullPath) )
{
$object->FieldErrors[$field_name]['pseudo'] = 'cant_save_file';
}
else
{
$real_name = $this->ValidateFileName($this->FullPath, $value['name']);
$file_name = $this->FullPath.$real_name;
if ( !move_uploaded_file($value['tmp_name'], $file_name) )
{
$object->FieldErrors[$field_name]['pseudo'] = 'cant_save_file';
}
else
{
@chmod($file_name, 0666);
if(getArrayValue($options, 'size_field'))
{
$object->SetDBField($options['size_field'], $value['size']);
}
if(getArrayValue($options, 'orig_name_field'))
{
$object->SetDBField($options['orig_name_field'], $value['name']);
}
if(getArrayValue($options, 'content_type_field'))
{
$object->SetDBField($options['content_type_field'], $value['type']);
}
$ret = getArrayValue($options, 'upload_dir') ? $real_name : $this->DestinationPath.$real_name;
// delete previous file, when new file is uploaded under same field
/*$previous_file = isset($value['upload']) ? $value['upload'] : false;
if ($previous_file && file_exists($this->FullPath.$previous_file)) {
unlink($this->FullPath.$previous_file);
}*/
}
}
}
else
{
$object->FieldErrors[$field_name]['pseudo'] = 'cant_save_file';
}
}
else
{
if(getArrayValue($options, 'required'))
{
$object->FieldErrors[$field_name]['pseudo'] = 'required';
}
}
if ($value['error'] && !( $value['error'] == UPLOAD_ERR_NO_FILE ) && !$object->FieldErrors[$field_name]['pseudo'])
{
$object->FieldErrors[$field_name]['pseudo'] = 'cant_save_file';
}
return $ret;
}
function Format($value, $field_name, &$object, $format=null)
{
if ( is_null($value) ) return '';
$options = $object->GetFieldOptions($field_name);
if ( isset($format) ) $options['format'] = $format;
$tc_value = $this->TypeCast($value, $options);
if( ($tc_value === false) || ($tc_value != $value) ) return $value; // for leaving badly formatted date on the form
return $this->GetFormatted($tc_value, $options);
}
function GetFormatted($tc_value, &$options)
{
if (isset($options['format'])) {
switch ($options['format']) {
case 'full_url':
$upload_dir = isset($options['upload_dir']) ? $options['upload_dir'] : $this->DestinationPath;
return rtrim($this->Application->BaseURL(), '/').$upload_dir.$tc_value;
break;
default:
return sprintf($options['format'], $tc_value);
break;
}
}
return $tc_value;
}
function ValidateFileName($path, $name)
{
$parts = pathinfo($name);
$ext = '.'.$parts['extension'];
$filename = substr($parts['basename'], 0, -strlen($ext));
$new_name = $filename.$ext;
while ( file_exists($path.'/'.$new_name) )
{
- if ( preg_match("/({$filename}_)([0-9]*)($ext)/", $new_name, $regs) ) {
+ if ( preg_match('/('.preg_quote($filename, '/').'_)([0-9]*)('.preg_quote($ext, '/').')/', $new_name, $regs) ) {
$new_name = $regs[1].($regs[2]+1).$regs[3];
}
else {
$new_name = $filename.'_1'.$ext;
}
}
return $new_name;
}
}
class kPictureFormatter extends kUploadFormatter
{
function kPictureFormatter()
{
$this->NakeLookupPath = IMAGES_PATH;
$this->DestinationPath = IMAGES_PENDING_PATH;
parent::kUploadFormatter();
}
function GetFormatted($tc_value, &$options)
{
if (isset($options['format']) && ($options['format'] == 'img_size')) {
$upload_dir = isset($options['upload_dir']) ? $options['upload_dir'] : $this->DestinationPath;
$img_path = FULL_PATH.'/'.$upload_dir.$tc_value;
$image_info = @getimagesize($img_path);
return ' width="'.$image_info[0].'" height="'.$image_info[1].'"';
}
return parent::GetFormatted($tc_value, $options);
}
}
\ No newline at end of file
Property changes on: trunk/core/kernel/utility/formatters/upload_formatter.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.4
\ No newline at end of property
+1.5
\ No newline at end of property
Index: trunk/core/units/theme_files/theme_files_config.php
===================================================================
--- trunk/core/units/theme_files/theme_files_config.php (nonexistent)
+++ trunk/core/units/theme_files/theme_files_config.php (revision 8074)
@@ -0,0 +1,62 @@
+<?php
+
+$config = Array(
+ 'Prefix' => 'theme-file',
+ 'ItemClass' => Array('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
+ 'ListClass' => Array('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
+ 'EventHandlerClass' => Array('class' => 'kDBEventHandler', 'file' => '', 'build_event'=>'OnBuild'),
+ 'TagProcessorClass' => Array('class' => 'kDBTagProcessor', 'file' => '', 'build_event'=>'OnBuild'),
+ 'AutoLoad' => true,
+
+ 'QueryString' => Array(
+ 1 => 'id',
+ 2 => 'page',
+ 3 => 'event',
+ ),
+
+ 'IDField' => 'FileId',
+
+ 'TitleField' => 'FileName',
+
+ 'TableName' => TABLE_PREFIX.'ThemeFiles',
+
+ 'ForeignKey' => 'ThemeId',
+ 'ParentTableKey' => 'ThemeId',
+ 'ParentPrefix' => 'theme',
+ 'AutoDelete' => true,
+ 'AutoClone' => true,
+
+ 'ListSQLs' => Array( '' => 'SELECT %1$s.* %2$s FROM %s'),
+ 'ItemSQLs' => Array( '' => 'SELECT %1$s.* %2$s FROM %s'),
+
+ 'ListSortings' => Array (
+ '' => Array(
+ 'Sorting' => Array('FileName' => 'asc'),
+ )
+ ),
+
+ 'Fields' => Array(
+ 'FileId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
+ 'ThemeId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
+ 'FileName' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''),
+ 'FilePath' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''),
+ 'Description' => Array ('type' => 'string', 'max_len' => 255, 'default' => NULL),
+ 'FileType' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
+ 'FileFound' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
+ ),
+
+ 'Grids' => Array (
+ 'Default' => Array (
+ 'Icons' => Array('default' => 'icon16_custom.gif'),
+ 'Fields' => Array (
+ 'FileId' => Array ('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter'),
+ 'FilePath' => Array( 'title'=>'la_col_FilePath',),
+ 'FileName' => Array( 'title'=>'la_col_FileName',),
+ 'Description' => Array( 'title'=>'la_col_Description',),
+ ),
+
+ ),
+ ),
+ );
+
+?>
\ No newline at end of file
Property changes on: trunk/core/units/theme_files/theme_files_config.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.1
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/core/units/themes/themes_config.php
===================================================================
--- trunk/core/units/themes/themes_config.php (revision 8073)
+++ trunk/core/units/themes/themes_config.php (revision 8074)
@@ -1,84 +1,84 @@
<?php
$config = Array(
'Prefix' => 'theme',
'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'),
'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
'EventHandlerClass' => Array('class'=>'ThemesEventHandler','file'=>'themes_eh.php','build_event'=>'OnBuild'),
'TagProcessorClass' => Array('class'=>'ThemesTagProcessor','file'=>'themes_tag_processor.php','build_event'=>'OnBuild'),
'AutoLoad' => true,
'Hooks' => Array(),
'QueryString' => Array(
1 => 'id',
2 => 'page',
3 => 'event',
4 => 'mode',
),
'IDField' => 'ThemeId',
'StatusField' => Array('Enabled', 'PrimaryTheme'),
'TitleField' => 'Name',
'TitlePresets' => Array (
'default' => Array (
'new_status_labels' => Array('theme' => '!la_title_Adding_Theme!'),
'edit_status_labels' => Array('theme' => '!la_title_Editing_Theme!'),
'new_titlefield' => Array('theme' => ''),
),
'themes_list' => Array('prefixes' => Array('theme_List'), 'format' => "!la_title_Configuration! - !la_title_Themes! (#theme_recordcount#)"),
'themes_edit_general' => Array('prefixes' => Array('theme'), 'format' => "#theme_status# '#theme_titlefield#' - !la_title_General!"),
- 'theme_files_list' => Array('prefixes' => Array('theme', 'theme-files_List'), 'format' => "#theme_status# '#theme_titlefield#' - !la_title_ThemeFiles! (#theme-files_recordcount#)"),
+ 'themes_edit_files' => Array('prefixes' => Array('theme', 'theme-file_List'), 'format' => "#theme_status# '#theme_titlefield#' - !la_title_ThemeFiles! (#theme-file_recordcount#)"),
),
'TableName' => TABLE_PREFIX.'Theme',
-// 'SubItems' => Array('themefiles'),
+ 'SubItems' => Array('theme-file'),
'FilterMenu' => Array(
'Groups' => Array(
Array('mode' => 'AND', 'filters' => Array(0,1), 'type' => WHERE_FILTER),
),
'Filters' => Array(
0 => Array('label' =>'la_Enabled', 'on_sql' => '', 'off_sql' => '%1$s.Enabled != 1' ),
1 => Array('label' => 'la_Disabled', 'on_sql' => '', 'off_sql' => '%1$s.Enabled != 0' ),
)
),
'AutoDelete' => true,
'AutoClone' => true,
'ListSQLs' => Array( '' => 'SELECT %1$s.* %2$s FROM %s'),
'ItemSQLs' => Array( '' => 'SELECT %1$s.* %2$s FROM %s'),
'ListSortings' => Array (
'' => Array(
'Sorting' => Array('Name' => 'asc'),
)
),
'Fields' => Array(
'ThemeId' => Array('type' => 'int', 'not_null' => 1, 'default' => 0),
'Name' => Array('type' => 'string','not_null' => 1, 'required' => 1, 'default' => ''),
'Enabled' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array(1=>'la_Enabled', 0=>'la_Disabled'), 'use_phrases'=>1, 'not_null' => 1, 'default' => 1),
'Description' => Array('type' => 'string','default' => null),
'PrimaryTheme' => Array('type' => 'int', 'not_null' => 1, 'default' => 0),
'CacheTimeout' => Array('type' => 'int', 'not_null' => 1, 'default' => 0),
'StylesheetId' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'Stylesheets', 'option_key_field' => 'StylesheetId', 'option_title_field' => 'Name', 'not_null' => 1, 'default' => 0),
),
'Grids' => Array(
'Default' => Array(
'Icons' => Array('default'=>'icon16_custom.gif', '1_1' => 'icon16_theme_primary.gif', '1_0' => 'icon16_theme.gif', '0_0' => 'icon16_theme_disabled.gif'),
'Fields' => Array(
'ThemeId' => Array ('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter'),
'Name' => Array( 'title'=>'la_col_Name',),
'Description' => Array( 'title'=>'la_col_Description', ),
'Enabled' => Array( 'title'=>'la_col_Status', 'filter_block' => 'grid_options_filter'),
),
),
),
);
?>
\ No newline at end of file
Property changes on: trunk/core/units/themes/themes_config.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.12
\ No newline at end of property
+1.13
\ No newline at end of property
Index: trunk/core/admin_templates/themes/themes_edit_files.tpl
===================================================================
--- trunk/core/admin_templates/themes/themes_edit_files.tpl (nonexistent)
+++ trunk/core/admin_templates/themes/themes_edit_files.tpl (revision 8074)
@@ -0,0 +1,77 @@
+<inp2:m_include t="incs/header"/>
+
+<inp2:m_RenderElement name="combined_header" section="in-portal:configure_themes" prefix="theme" title_preset="themes_edit_files" tabs="themes/themes_edit_tabs"/>
+
+<!-- ToolBar --->
+<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
+<tbody>
+ <tr>
+ <td>
+ <script type="text/javascript">
+
+ function edit()
+ {
+
+ }
+
+ a_toolbar = new ToolBar();
+ a_toolbar.AddButton( new ToolBarButton('select', '<inp2:m_phrase label="la_ToolTip_Save" escape="1"/>', function() {
+ submit_event('theme','<inp2:theme_SaveEvent/>');
+ }
+ ) );
+ a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() {
+ submit_event('theme','OnCancelEdit');
+ }
+ ) );
+
+ a_toolbar.AddButton( new ToolBarSeparator('sep1') );
+
+ a_toolbar.AddButton( new ToolBarButton('prev', '<inp2:m_phrase label="la_ToolTip_Prev" escape="1"/>', function() {
+ go_to_id('theme', '<inp2:theme_PrevId/>');
+ }
+ ) );
+ a_toolbar.AddButton( new ToolBarButton('next', '<inp2:m_phrase label="la_ToolTip_Next" escape="1"/>', function() {
+ go_to_id('theme', '<inp2:theme_NextId/>');
+ }
+ ) );
+
+ a_toolbar.AddButton( new ToolBarSeparator('sep2') );
+
+ a_toolbar.AddButton( new ToolBarButton('delete', '<inp2:m_phrase label="la_ToolTip_Delete" escape="1"/>',
+ function() {
+ std_delete_items('theme-file')
+ } ) );
+
+ a_toolbar.AddButton( new ToolBarSeparator('sep3') );
+
+ a_toolbar.AddButton( new ToolBarButton('view', '<inp2:m_phrase label="la_ToolTip_View" escape="1"/>', function() {
+ show_viewmenu(a_toolbar,'view');
+ }
+ ) );
+
+ a_toolbar.Render();
+
+ <inp2:m_if prefix="theme" function="IsSingle"/>
+ a_toolbar.HideButton('prev');
+ a_toolbar.HideButton('next');
+ a_toolbar.HideButton('sep1');
+ <inp2:m_else/>
+ <inp2:m_if prefix="theme" function="IsLast"/>
+ a_toolbar.DisableButton('next');
+ <inp2:m_endif/>
+ <inp2:m_if prefix="theme" function="IsFirst"/>
+ a_toolbar.DisableButton('prev');
+ <inp2:m_endif/>
+ <inp2:m_endif/>
+ </script>
+ </td>
+ <inp2:m_RenderElement name="search_main_toolbar" prefix="theme-file" grid="Default"/>
+ </tr>
+</tbody>
+</table>
+
+<inp2:m_ParseBlock name="grid" PrefixSpecial="theme-file" IdField="FileId" grid="Default"/>
+<script type="text/javascript">
+// Grids['theme-file'].SetDependantToolbarButtons( new Array('edit','delete') );
+</script>
+<inp2:m_include t="incs/footer"/>
\ No newline at end of file
Property changes on: trunk/core/admin_templates/themes/themes_edit_files.tpl
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.1
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Event Timeline
Log In to Comment