Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F804476
configuration_tag_processor.php
No One
Temporary
Actions
Download 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, 11:53 AM
Size
5 KB
Mime Type
text/x-php
Expires
Fri, Feb 28, 11:53 AM (22 h, 54 m)
Engine
blob
Format
Raw Data
Handle
577013
Attached To
rINP In-Portal
configuration_tag_processor.php
View Options
<?php
class
ConfigurationTagProcessor
extends
kDBTagProcessor
{
function
Init
(
$prefix
,
$special
,
$event_params
=
null
)
{
parent
::
Init
(
$prefix
,
$special
,
$event_params
);
$this
->
Application
->
LinkVar
(
'module_key'
);
}
/**
* Prints list content using block specified
*
* @param Array $params
* @return string
* @access public
*/
function
PrintList
(
$params
)
{
$list
=&
$this
->
GetList
(
$params
);
$id_field
=
$this
->
Application
->
getUnitOption
(
$this
->
Prefix
,
'IDField'
);
$list
->
Query
();
$o
=
''
;
$list
->
GoFirst
();
$block_params
=
$this
->
prepareTagParams
(
$params
);
// $block_params['name'] = $this->SelectParam($params, 'render_as,block');
$block_params
[
'pass_params'
]
=
'true'
;
$block_params
[
'IdField'
]
=
$list
->
IDField
;
$prev_heading
=
''
;
$next_block
=
$params
[
'full_block'
];
$this
->
groupRecords
(
$list
->
Records
,
'heading'
);
$field_values
=
$this
->
Application
->
GetVar
(
$this
->
getPrefixSpecial
(
true
));
while
(!
$list
->
EOL
())
{
$this
->
Application
->
SetVar
(
$this
->
getPrefixSpecial
().
'_id'
,
$list
->
GetDBField
(
$id_field
)
);
// for edit/delete links using GET
// using 2 blocks for drawing o row in case if current & next record titles match
$next_item_prompt
=
$list
->
CurrentIndex
+
1
<
$list
->
RecordsCount
?
$list
->
Records
[
$list
->
CurrentIndex
+
1
][
'prompt'
]
:
''
;
$this_item_prompt
=
$list
->
GetDBField
(
'prompt'
);
if
(
$next_item_prompt
==
$this_item_prompt
)
{
$curr_block
=
$params
[
'half_block1'
];
$next_block
=
$params
[
'half_block2'
];
}
else
{
$curr_block
=
$next_block
;
$next_block
=
$params
[
'full_block'
];
}
$block_params
[
'name'
]
=
$curr_block
;
$block_params
[
'show_heading'
]
=
(
$prev_heading
!=
$list
->
GetDBField
(
'heading'
)
)
?
1
:
0
;
// set values from submit if any
if
(
$field_values
)
{
$list
->
SetDBField
(
'VariableValue'
,
$field_values
[
$list
->
GetDBField
(
'VariableName'
)][
'VariableValue'
]);
}
$o
.=
$this
->
Application
->
ParseBlock
(
$block_params
,
1
);
$prev_heading
=
$list
->
GetDBField
(
'heading'
);
$list
->
GoNext
();
}
$this
->
Application
->
RemoveVar
(
'ModuleRootCategory'
);
$this
->
Application
->
SetVar
(
$this
->
getPrefixSpecial
().
'_id'
,
''
);
return
$o
;
}
function
getModuleItemName
()
{
$module
=
$this
->
Application
->
GetVar
(
'module'
);
$table
=
$this
->
Application
->
getUnitOption
(
'confs'
,
'TableName'
);
$sql
=
'SELECT ConfigHeader
FROM '
.
$table
.
'
WHERE ModuleName = '
.
$this
->
Conn
->
qstr
(
$module
);
return
$this
->
Conn
->
GetOne
(
$sql
);
}
function
PrintConfList
(
$params
)
{
$list
=&
$this
->
GetList
(
$params
);
$id_field
=
$this
->
Application
->
getUnitOption
(
$this
->
Prefix
,
'IDField'
);
$list
->
PerPage
=
-
1
;
$list
->
Query
();
$o
=
''
;
$list
->
GoFirst
();
$tmp_row
=
Array
();
while
(!
$list
->
EOL
())
{
$rec
=
$list
->
getCurrentRecord
();
$tmp_row
[
0
][
$rec
[
'VariableName'
]]
=
$rec
[
'VariableValue'
];
$tmp_row
[
0
][
$rec
[
'VariableName'
].
'_prompt'
]
=
$rec
[
'prompt'
];
$list
->
GoNext
();
}
$list
->
Records
=
$tmp_row
;
$block_params
=
$this
->
prepareTagParams
(
$params
);
$block_params
[
'name'
]
=
$this
->
SelectParam
(
$params
,
'render_as,block'
);
$block_params
[
'module_key'
]
=
$this
->
Application
->
GetVar
(
'module_key'
);
$block_params
[
'module_item'
]
=
$this
->
getModuleItemName
();
$list
->
GoFirst
();
return
$this
->
Application
->
ParseBlock
(
$block_params
,
1
);
}
function
ShowRelevance
(
$params
)
{
return
$this
->
Application
->
GetVar
(
'module_key'
)
!=
'_'
;
}
function
ConfigValue
(
$params
)
{
return
$this
->
Application
->
ConfigValue
(
$params
[
'name'
]);
}
function
Error
(
$params
)
{
$object
=&
$this
->
Application
->
recallObject
(
$this
->
getPrefixSpecial
()
);
$field
=
$object
->
GetDBField
(
$params
[
'id_field'
]);
$errors
=
$this
->
Application
->
GetVar
(
'errormsgs'
);
$errors
=
$errors
[
$this
->
getPrefixSpecial
()];
if
(
isset
(
$errors
[
$field
]))
{
$msg
=
$this
->
Application
->
Phrase
(
$errors
[
$field
]);
}
else
{
$msg
=
''
;
}
return
$msg
;
}
/**
* Allows to show category path of selected module
*
* @param Array $params
* @return string
*/
function
CategoryPath
(
$params
)
{
if
(!
isset
(
$params
[
'cat_id'
]))
{
$params
[
'cat_id'
]
=
$this
->
ModuleRootCategory
(
Array
()
);
}
$block_params
[
'current'
]
=
1
;
$block_params
[
'separator'
]
=
$params
[
'separator'
];
if
(
$params
[
'cat_id'
]
==
0
)
{
$block_params
[
'name'
]
=
$params
[
'rootcatblock'
];
return
$this
->
Application
->
ParseBlock
(
$block_params
);
}
else
{
$cat_object
=&
$this
->
Application
->
recallObject
(
$this
->
getPrefixSpecial
(),
$this
->
Prefix
.
'_List'
);
$sql
=
'SELECT CategoryId, ParentId, Name FROM '
.
TABLE_PREFIX
.
'Category WHERE CategoryId='
.
$params
[
'cat_id'
];
$res
=
$this
->
Conn
->
GetRow
(
$sql
);
if
(
$res
===
false
)
{
// in case if category is deleted
return
''
;
}
$block_params
[
'name'
]
=
$params
[
'block'
];
$block_params
[
'cat_name'
]
=
$res
[
'Name'
];
$block_params
[
'separator'
]
=
$params
[
'separator'
];
$block_params
[
'cat_id'
]
=
$res
[
'CategoryId'
];
$next_params
[
'separator'
]
=
$params
[
'separator'
];
$next_params
[
'rootcatblock'
]
=
$params
[
'rootcatblock'
];
$next_params
[
'block'
]
=
$params
[
'block'
];
$next_params
[
'cat_id'
]
=
$res
[
'ParentId'
];
return
$this
->
CategoryPath
(
$next_params
).
$this
->
Application
->
ParseBlock
(
$block_params
);
}
}
/**
* Shows edit warning in case if module root category changed but not saved
*
* @param Array $params
* @return string
*/
function
SaveWarning
(
$params
)
{
$temp_category_id
=
$this
->
Application
->
RecallVar
(
'ModuleRootCategory'
);
if
(
$temp_category_id
!==
false
)
{
return
$this
->
Application
->
ParseBlock
(
$params
);
}
return
''
;
}
function
ModuleRootCategory
(
$params
)
{
$category_id
=
$this
->
Application
->
RecallVar
(
'ModuleRootCategory'
);
if
(
$category_id
===
false
)
{
$category_id
=
$this
->
Application
->
findModule
(
'Name'
,
$this
->
Application
->
GetVar
(
'module'
),
'RootCat'
);
}
return
$category_id
;
}
}
?>
Event Timeline
Log In to Comment