Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1050805
categories_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
Thu, Jul 3, 3:50 PM
Size
19 KB
Mime Type
text/x-php
Expires
Sat, Jul 5, 3:50 PM (21 h, 2 m)
Engine
blob
Format
Raw Data
Handle
678990
Attached To
rINP In-Portal
categories_tag_processor.php
View Options
<?php
class
CategoriesTagProcessor
extends
kDBTagProcessor
{
function
SubCatCount
(
$params
)
{
$object
=&
$this
->
getObject
(
$params
);
if
(
isset
(
$params
[
'today'
])
&&
$params
[
'today'
])
{
$sql
=
'SELECT COUNT(*)
FROM '
.
$object
->
TableName
.
'
WHERE (ParentPath LIKE "'
.
$object
->
GetDBField
(
'ParentPath'
).
'%") AND (CreatedOn > '
.(
adodb_mktime
()
-
86400
).
')'
;
return
$this
->
Conn
->
GetOne
(
$sql
)
-
1
;
}
return
$object
->
GetDBField
(
'CachedDescendantCatsQty'
);
}
/**
* Returns category count in system
*
* @param Array $params
* @return int
*/
function
CategoryCount
(
$params
)
{
$count_helper
=&
$this
->
Application
->
recallObject
(
'CountHelper'
);
/* @var $count_helper kCountHelper */
$today_only
=
isset
(
$params
[
'today'
])
&&
$params
[
'today'
];
return
$count_helper
->
CategoryCount
(
$today_only
);
}
function
IsNew
(
$params
)
{
$object
=&
$this
->
getObject
(
$params
);
return
$object
->
GetDBField
(
'IsNew'
)
?
1
:
0
;
}
function
IsPick
(
$params
)
{
return
$this
->
IsEditorsPick
(
$params
);
}
/**
* Returns item's editors pick status (using not formatted value)
*
* @param Array $params
* @return bool
*/
function
IsEditorsPick
(
$params
)
{
$object
=&
$this
->
getObject
(
$params
);
return
$object
->
GetDBField
(
'EditorsPick'
)
==
1
;
}
function
ItemIcon
(
$params
)
{
// only for categories, not structure
if
(
$this
->
Prefix
!=
'c'
)
{
return
parent
::
ItemIcon
(
$params
);
}
$object
=&
$this
->
Application
->
recallObject
(
$this
->
getPrefixSpecial
(),
$this
->
Prefix
,
$params
);
$status
=
$object
->
GetDBField
(
'Status'
);
if
(
$status
==
1
)
{
$ret
=
$object
->
GetDBField
(
'IsNew'
)
?
'icon16_cat_new.gif'
:
'icon16_cat.gif'
;
}
else
{
$ret
=
$status
?
'icon16_cat_pending.gif'
:
'icon16_cat_disabled.gif'
;
}
return
$ret
;
}
function
ItemCount
(
$params
)
{
$cat_object
=&
$this
->
getObject
(
$params
);
$ci_table
=
$this
->
Application
->
getUnitOption
(
'l-ci'
,
'TableName'
);
$sql
=
'SELECT COUNT(*)
FROM '
.
$cat_object
->
TableName
.
' c
LEFT JOIN '
.
$ci_table
.
' ci ON c.CategoryId=ci.CategoryId
WHERE c.ParentPath LIKE "'
.
$cat_object
->
GetDBField
(
'ParentPath'
).
'%" AND NOT (ci.CategoryId IS NULL)'
;
return
$this
->
Conn
->
GetOne
(
$sql
);
}
function
ListCategories
(
$params
)
{
return
$this
->
PrintList2
(
$params
);
}
function
RootCategoryName
(
$params
)
{
return
$this
->
Application
->
ProcessParsedTag
(
'm'
,
'RootCategoryName'
,
$params
);
}
function
CheckModuleRoot
(
$params
)
{
$module_name
=
getArrayValue
(
$params
,
'module'
)
?
$params
[
'module'
]
:
'In-Commerce'
;
$module_root_cat
=
$this
->
Application
->
findModule
(
'Name'
,
$module_name
,
'RootCat'
);
$additional_cats
=
$this
->
SelectParam
(
$params
,
'add_cats'
);
if
(
$additional_cats
)
{
$additional_cats
=
explode
(
','
,
$additional_cats
);
}
else
{
$additional_cats
=
array
();
}
if
(
$this
->
Application
->
GetVar
(
'm_cat_id'
)
==
$module_root_cat
||
in_array
(
$this
->
Application
->
GetVar
(
'm_cat_id'
),
$additional_cats
))
{
$home_template
=
getArrayValue
(
$params
,
'home_template'
);
if
(!
$home_template
)
return
;
$this
->
Application
->
Redirect
(
$home_template
,
Array
(
'pass'
=>
'all'
));
};
}
function
CategoryPath
(
$params
)
{
$category_helper
=&
$this
->
Application
->
recallObject
(
'CategoryHelper'
);
/* @var $category_helper CategoryHelper */
return
$category_helper
->
NavigationBar
(
$params
);
}
/**
* Allows to show category path of selected module
*
* @param Array $params
* @return string
*/
function
FieldCategoryPath
(
$params
)
{
$object
=&
$this
->
getObject
();
/* @var $object kDBItem */
$field
=
$this
->
SelectParam
(
$params
,
'name,field'
);
$category_id
=
$object
->
GetDBField
(
$field
);
if
(
$category_id
)
{
$params
[
'cat_id'
]
=
$category_id
;
return
$this
->
CategoryPath
(
$params
);
}
return
''
;
}
function
CurrentCategoryName
(
$params
)
{
$cat_object
=&
$this
->
Application
->
recallObject
(
$this
->
getPrefixSpecial
(),
$this
->
Prefix
.
'_List'
);
$sql
=
'SELECT '
.
$this
->
getTitleField
().
'
FROM '
.
$cat_object
->
TableName
.
'
WHERE CategoryId = '
.
$this
->
Application
->
GetVar
(
'm_cat_id'
);
return
$this
->
Conn
->
GetOne
(
$sql
);
}
function
getTitleField
()
{
$ml_formatter
=&
$this
->
Application
->
recallObject
(
'kMultiLanguage'
);
return
$ml_formatter
->
LangFieldName
(
'Name'
);
}
function
getCategorySymLink
(
$category_id
)
{
static
$cache
=
null
;
if
(!
isset
(
$cache
))
{
$id_field
=
$this
->
Application
->
getUnitOption
(
$this
->
Prefix
,
'IDField'
);
$table_name
=
$this
->
Application
->
getUnitOption
(
$this
->
Prefix
,
'TableName'
);
$sql
=
'SELECT SymLinkCategoryId, '
.
$id_field
.
'
FROM '
.
$table_name
.
'
WHERE SymLinkCategoryId IS NOT NULL'
;
$cache
=
$this
->
Conn
->
GetCol
(
$sql
,
$id_field
);
}
if
(
isset
(
$cache
[
$category_id
]))
{
//check if sym. link category is valid
$id_field
=
$this
->
Application
->
getUnitOption
(
$this
->
Prefix
,
'IDField'
);
$table_name
=
$this
->
Application
->
getUnitOption
(
$this
->
Prefix
,
'TableName'
);
$sql
=
'SELECT '
.
$id_field
.
'
FROM '
.
$table_name
.
'
WHERE '
.
$id_field
.
' = '
.
$cache
[
$category_id
];
$category_id
=
$this
->
Conn
->
GetOne
(
$sql
)?
$cache
[
$category_id
]
:
$category_id
;
}
return
$category_id
;
}
function
CategoryLink
(
$params
)
{
$category_id
=
getArrayValue
(
$params
,
'cat_id'
);
if
(
$category_id
===
false
)
{
$category_id
=
$this
->
Application
->
GetVar
(
$this
->
getPrefixSpecial
().
'_id'
);
}
if
(
"$category_id"
==
'Root'
)
{
$category_id
=
$this
->
Application
->
findModule
(
'Name'
,
$params
[
'module'
],
'RootCat'
);
}
elseif
(
"$category_id"
==
'current'
)
{
$category_id
=
$this
->
Application
->
GetVar
(
'm_cat_id'
);
}
$category_id
=
$this
->
getCategorySymLink
(
$category_id
);
unset
(
$params
[
'cat_id'
],
$params
[
'module'
]);
$new_params
=
Array
(
'pass'
=>
'm'
,
'm_cat_id'
=>
$category_id
,
'pass_category'
=>
1
);
$params
=
array_merge_recursive2
(
$params
,
$new_params
);
return
$this
->
Application
->
ProcessParsedTag
(
'm'
,
't'
,
$params
);
}
function
CategoryList
(
$params
)
{
//$object =& $this->Application->recallObject( $this->getPrefixSpecial() , $this->Prefix.'_List', $params );
$object
=&
$this
->
GetList
(
$params
);
if
(
$object
->
RecordsCount
==
0
)
{
if
(
isset
(
$params
[
'block_no_cats'
]))
{
$params
[
'name'
]
=
$params
[
'block_no_cats'
];
return
$this
->
Application
->
ParseBlock
(
$params
);
}
else
{
return
''
;
}
}
if
(
isset
(
$params
[
'block'
]))
{
return
$this
->
PrintList
(
$params
);
}
else
{
$params
[
'block'
]
=
$params
[
'block_main'
];
if
(
isset
(
$params
[
'block_row_start'
]))
{
$params
[
'row_start_block'
]
=
$params
[
'block_row_start'
];
}
if
(
isset
(
$params
[
'block_row_end'
]))
{
$params
[
'row_end_block'
]
=
$params
[
'block_row_end'
];
}
return
$this
->
PrintList2
(
$params
);
}
}
function
Meta
(
$params
)
{
$name
=
getArrayValue
(
$params
,
'name'
);
$object
=&
$this
->
Application
->
recallObject
(
$this
->
Prefix
.
'.-item'
);
$field
=
$object
->
GetField
(
'Meta'
.
$name
);
if
(
$field
)
return
$field
;
switch
(
$name
)
{
case
'Description'
:
$conf
=
'Category_MetaDesc'
;
break
;
case
'Keywords'
:
$conf
=
'Category_MetaKey'
;
break
;
}
return
$this
->
Application
->
ConfigValue
(
$conf
);
}
function
BuildListSpecial
(
$params
)
{
if
(
isset
(
$params
[
'parent_cat_id'
])
)
{
$parent_cat_id
=
$params
[
'parent_cat_id'
];
}
else
{
$parent_cat_id
=
$this
->
Application
->
GetVar
(
$this
->
Prefix
.
'_id'
);
if
(!
$parent_cat_id
)
{
$parent_cat_id
=
$this
->
Application
->
GetVar
(
'm_cat_id'
);
}
if
(!
$parent_cat_id
)
{
$parent_cat_id
=
0
;
}
}
$types
=
$this
->
SelectParam
(
$params
,
'types'
);
$except
=
$this
->
SelectParam
(
$params
,
'except'
);
$no_special
=
isset
(
$params
[
'no_special'
])
&&
$params
[
'no_special'
];
if
(
$no_special
)
return
$this
->
Special
;
if
(
$types
.
$except
.
$parent_cat_id
==
''
)
{
return
parent
::
BuildListSpecial
(
$params
);
}
$special
=
crc32
(
$types
.
$except
.
$parent_cat_id
);
return
$special
;
}
function
IsCurrent
(
$params
)
{
$object
=&
$this
->
getObject
(
$params
);
if
(
$object
->
GetID
()
==
$this
->
Application
->
GetVar
(
'm_cat_id'
))
{
return
true
;
}
else
{
return
false
;
}
}
/**
* Substitutes category in last template base on current category
* This is required becasue when you navigate catalog using AJAX, last_template is not updated
* but when you open item edit from catalog last_template is used to build opener_stack
* So, if we don't substitute m_cat_id in last_template, after saving item we'll get redirected
* to the first category we've opened, not the one we navigated to using AJAX
*
* @param Array $params
*/
function
UpdateLastTemplate
(
$params
)
{
$category_id
=
$this
->
Application
->
GetVar
(
'm_cat_id'
);
$wid
=
$this
->
Application
->
GetVar
(
'm_wid'
);
list
(
$index_file
,
$env
)
=
explode
(
'|'
,
$this
->
Application
->
RecallVar
(
rtrim
(
'last_template_'
.
$wid
,
'_'
)),
2
);
$this
->
Application
->
SetVar
(
ENV_VAR_NAME
,
str_replace
(
'%5C'
,
'
\\
'
,
$env
));
$this
->
Application
->
HttpQuery
->
processQueryString
();
// update required fields
$this
->
Application
->
SetVar
(
'm_cat_id'
,
$category_id
);
$this
->
Application
->
Session
->
SaveLastTemplate
(
$params
[
'template'
]);
}
function
GetParentCategory
(
$params
)
{
$parent_id
=
0
;
$id_field
=
$this
->
Application
->
getUnitOption
(
$this
->
Prefix
,
'IDField'
);
$table
=
$this
->
Application
->
getUnitOption
(
$this
->
Prefix
,
'TableName'
);
$cat_id
=
$this
->
Application
->
GetVar
(
'm_cat_id'
);
if
(
$cat_id
>
0
)
{
$sql
=
'SELECT ParentId
FROM '
.
$table
.
'
WHERE '
.
$id_field
.
' = '
.
$cat_id
;
$parent_id
=
$this
->
Conn
->
GetOne
(
$sql
);
}
return
$parent_id
;
}
function
InitCacheUpdater
(
$params
)
{
safeDefine
(
'CACHE_PERM_CHUNK_SIZE'
,
30
);
$continue
=
$this
->
Application
->
GetVar
(
'continue'
);
$total_cats
=
(
int
)
$this
->
Conn
->
GetOne
(
'SELECT COUNT(*) FROM '
.
TABLE_PREFIX
.
'Category'
);
if
(
$continue
===
false
&&
$total_cats
>
CACHE_PERM_CHUNK_SIZE
)
{
// first step, if category count > CACHE_PERM_CHUNK_SIZE, then ask for cache update
return
true
;
}
if
(
$continue
===
false
)
{
// if we don't have to ask, then assume user selected "Yes" in permcache update dialog
$continue
=
1
;
}
$updater
=&
$this
->
Application
->
recallObject
(
'kPermCacheUpdater'
,
null
,
Array
(
'continue'
=>
$continue
));
/* @var $updater kPermCacheUpdater */
if
(
$continue
===
'0'
)
{
// No in dialog
$updater
->
clearData
();
$this
->
Application
->
Redirect
(
$params
[
'destination_template'
]);
}
$ret
=
false
;
// don't ask for update
if
(
$continue
==
1
)
{
// Initial run
$updater
->
setData
();
}
if
(
$continue
==
2
)
{
// Continuing
// called from AJAX request => returns percent
$needs_more
=
true
;
while
(
$needs_more
&&
$updater
->
iteration
<=
CACHE_PERM_CHUNK_SIZE
)
{
// until proceeeded in this step category count exceeds category per step limit
$needs_more
=
$updater
->
DoTheJob
();
}
if
(
$needs_more
)
{
// still some categories are left for next step
$updater
->
setData
();
}
else
{
// all done -> redirect
$updater
->
SaveData
();
$this
->
Application
->
RemoveVar
(
'PermCache_UpdateRequired'
);
$this
->
Application
->
Redirect
(
$params
[
'destination_template'
]);
}
$ret
=
$updater
->
getDonePercent
();
}
return
$ret
;
}
/**
* Parses warning block, but with style="display: none;". Used during permissions saving from AJAX
*
* @param Array $params
* @return string
*/
function
SaveWarning
(
$params
)
{
if
(
$this
->
Prefix
!=
'c'
)
{
// don't use this method for other prefixes then Category, that use this tag processor
parent
::
SaveWarning
(
$params
);
return
;
}
$main_prefix
=
getArrayValue
(
$params
,
'main_prefix'
);
if
(
$main_prefix
&&
$main_prefix
!=
'$main_prefix'
)
{
$top_prefix
=
$main_prefix
;
}
else
{
$top_prefix
=
$this
->
Application
->
GetTopmostPrefix
(
$this
->
Prefix
);
}
$temp_tables
=
substr
(
$this
->
Application
->
GetVar
(
$top_prefix
.
'_mode'
),
0
,
1
)
==
't'
;
$modified
=
$this
->
Application
->
RecallVar
(
$top_prefix
.
'_modified'
);
if
(!
$temp_tables
)
{
$this
->
Application
->
RemoveVar
(
$top_prefix
.
'_modified'
);
return
''
;
}
$block_name
=
$this
->
SelectParam
(
$params
,
'render_as,name'
);
if
(
$block_name
)
{
$block_params
=
$this
->
prepareTagParams
(
$params
);
$block_params
[
'name'
]
=
$block_name
;
$block_params
[
'edit_mode'
]
=
$temp_tables
?
1
:
0
;
$block_params
[
'display'
]
=
$temp_tables
&&
$modified
?
1
:
0
;
return
$this
->
Application
->
ParseBlock
(
$block_params
);
}
else
{
return
$temp_tables
&&
$modified
?
1
:
0
;
}
return
;
}
/**
* Allows to detect if this prefix has something in clipboard
*
* @param Array $params
* @return bool
*/
function
HasClipboard
(
$params
)
{
$clipboard
=
$this
->
Application
->
RecallVar
(
'clipboard'
);
if
(
$clipboard
)
{
$clipboard
=
unserialize
(
$clipboard
);
foreach
(
$clipboard
as
$prefix
=>
$clipboard_data
)
{
foreach
(
$clipboard_data
as
$mode
=>
$ids
)
{
if
(
count
(
$ids
))
return
1
;
}
}
}
return
0
;
}
/**
* Allows to detect if root category being edited
*
* @param Array $params
*/
function
IsRootCategory
(
$params
)
{
$object
=&
$this
->
getObject
(
$params
);
return
$object
->
IsRoot
();
}
function
CatalogItemCount
(
$params
)
{
$object
=&
$this
->
GetList
(
$params
);
if
(!
$object
->
Counted
)
{
$object
->
CountRecs
();
}
return
$object
->
NoFilterCount
!=
$object
->
RecordsCount
?
$object
->
RecordsCount
.
' / '
.
$object
->
NoFilterCount
:
$object
->
RecordsCount
;
}
/**
* Print grid pagination using
* block names specified
*
* @param Array $params
* @return string
* @access public
*/
function
PrintPages
(
$params
)
{
if
(
$this
->
Application
->
Parser
->
GetParam
(
'no_special'
))
{
$params
[
'no_special'
]
=
$this
->
Application
->
Parser
->
GetParam
(
'no_special'
);
}
return
parent
::
PrintPages
(
$params
);
}
function
InitCatalog
(
$params
)
{
$tab_prefixes
=
$this
->
Application
->
GetVar
(
'tp'
);
// {all, <prefixes_list>, none}
if
(
$tab_prefixes
===
false
)
$tab_prefixes
=
'all'
;
$skip_prefixes
=
isset
(
$params
[
'skip_prefixes'
])
&&
$params
[
'skip_prefixes'
]
?
explode
(
','
,
$params
[
'skip_prefixes'
])
:
Array
();
// get all prefixes available
$prefixes
=
Array
();
foreach
(
$this
->
Application
->
ModuleInfo
as
$module_name
=>
$module_data
)
{
if
(
$module_data
[
'Var'
]
==
'm'
)
continue
;
$prefixes
[]
=
$module_data
[
'Var'
];
}
if
(
$tab_prefixes
==
'none'
)
{
$skip_prefixes
=
array_unique
(
array_merge
(
$skip_prefixes
,
$prefixes
));
}
elseif
(
$tab_prefixes
!=
'all'
)
{
// prefix list here
$tab_prefixes
=
explode
(
','
,
$tab_prefixes
);
// list of prefixes that should stay
$skip_prefixes
=
array_unique
(
array_merge
(
$skip_prefixes
,
array_diff
(
$prefixes
,
$tab_prefixes
)));
}
$params
[
'name'
]
=
$params
[
'render_as'
];
$params
[
'skip_prefixes'
]
=
implode
(
','
,
$skip_prefixes
);
return
$this
->
Application
->
ParseBlock
(
$params
,
1
);
}
function
IsActive
(
$params
)
{
$cat_id
=
isset
(
$params
[
'cat_id'
])
&&
$params
[
'cat_id'
]
?
$params
[
'cat_id'
]
:
false
;
if
(
$cat_id
===
false
)
{
// category not supplied -> get current from PrintList
$cat_id
=
$this
->
Application
->
GetVar
(
$this
->
getPrefixSpecial
().
'_id'
);
$current_cat
=&
$this
->
getObject
(
$params
);
}
else
{
if
(
"$cat_id"
==
'Root'
)
{
$cat_id
=
$this
->
Application
->
findModule
(
'Name'
,
$params
[
'module'
],
'RootCat'
);
}
$current_cat
=&
$this
->
Application
->
recallObject
(
$this
->
Prefix
.
'.-c'
.
$cat_id
,
$this
->
Prefix
,
Array
(
'skip_autoload'
=>
true
));
$current_cat
->
Load
(
$cat_id
);
}
$current_path
=
$current_cat
->
GetDBField
(
'ParentPath'
);
static
$parent_path
=
null
;
if
(!
isset
(
$parent_path
))
{
$parent_path
=
$this
->
Conn
->
GetOne
(
'SELECT ParentPath FROM '
.
TABLE_PREFIX
.
'Category WHERE CategoryId = '
.
$this
->
Application
->
GetVar
(
'm_cat_id'
));
}
return
strpos
(
$parent_path
,
$current_path
)
!==
false
;
}
/**
* Checks if user have one of required permissions
*
* @param Array $params
* @return bool
*/
function
HasPermission
(
$params
)
{
$perm_helper
=&
$this
->
Application
->
recallObject
(
'PermissionsHelper'
);
/* @var $perm_helper kPermissionsHelper */
$params
[
'raise_warnings'
]
=
0
;
$object
=&
$this
->
getObject
(
$params
);
/* @var $object kDBItem */
$params
[
'cat_id'
]
=
$object
->
isLoaded
()
?
$object
->
GetDBField
(
'ParentPath'
)
:
$this
->
Application
->
GetVar
(
'm_cat_id'
);
return
$perm_helper
->
TagPermissionCheck
(
$params
);
}
/**
* Prepares name for field with event in it (used only on front-end)
*
* @param Array $params
* @return string
*/
function
SubmitName
(
$params
)
{
return
'events['
.
$this
->
Prefix
.
']['
.
$params
[
'event'
].
']'
;
}
/**
* Returns last modification date of items in category / system
*
* @param Array $params
* @return string
*/
function
LastUpdated
(
$params
)
{
$category_id
=
$this
->
Application
->
GetVar
(
'm_cat_id'
);
$table_name
=
$this
->
Application
->
getUnitOption
(
$this
->
Prefix
,
'TableName'
);
if
(
isset
(
$params
[
'local'
])
&&
$params
[
'local'
]
&&
$category_id
>
0
)
{
// scan only current category & it's children
$sql
=
'SELECT TreeLeft, TreeRight
FROM '
.
TABLE_PREFIX
.
'Category
WHERE CategoryId = '
.
$category_id
;
$tree_info
=
$this
->
Conn
->
GetRow
(
$sql
);
$sql
=
'SELECT MAX(c.Modified) AS ModDate, MAX(c.CreatedOn) AS NewDate
FROM '
.
TABLE_PREFIX
.
'Category c
WHERE c.TreeLeft BETWEEN '
.
$tree_info
[
'TreeLeft'
].
' AND '
.
$tree_info
[
'TreeRight'
];
}
else
{
// scan all categories in system
$sql
=
'SELECT MAX(Modified) AS ModDate, MAX(CreatedOn) AS NewDate
FROM '
.
$table_name
;
}
$row_data
=
$this
->
Conn
->
GetRow
(
$sql
);
if
(!
$row_data
)
{
return
''
;
}
$date
=
$row_data
[
$row_data
[
'NewDate'
]
>
$row_data
[
'ModDate'
]
?
'NewDate'
:
'ModDate'
];
// format date
$format
=
isset
(
$params
[
'format'
])
?
$params
[
'format'
]
:
'_regional_DateTimeFormat'
;
if
(
preg_match
(
"/_regional_(.*)/"
,
$format
,
$regs
))
{
$lang
=&
$this
->
Application
->
recallObject
(
'lang.current'
);
if
(
$regs
[
1
]
==
'DateTimeFormat'
)
{
// combined format
$format
=
$lang
->
GetDBField
(
'DateFormat'
).
' '
.
$lang
->
GetDBField
(
'TimeFormat'
);
}
else
{
// simple format
$format
=
$lang
->
GetDBField
(
$regs
[
1
]);
}
}
return
adodb_date
(
$format
,
$date
);
}
function
CategoryItemCount
(
$params
)
{
$object
=&
$this
->
getObject
(
$params
);
/* @var $object kDBList */
$params
[
'cat_id'
]
=
$object
->
GetID
();
$count_helper
=&
$this
->
Application
->
recallObject
(
'CountHelper'
);
/* @var $count_helper kCountHelper */
return
$count_helper
->
CategoryItemCount
(
$params
[
'prefix'
],
$params
);
}
/**
* Returns prefix + any word (used for shared between categories per page settings)
*
* @param Array $params
* @return string
*/
function
VarName
(
$params
)
{
return
$this
->
Prefix
.
'_'
.
$params
[
'type'
];
}
/**
* Checks if current category is valid symbolic link to another category
*
* @param Array $params
* @return string
*/
function
IsCategorySymLink
(
$params
)
{
$object
=&
$this
->
getObject
(
$params
);
/* @var $object kDBList */
$sym_category_id
=
$object
->
GetDBField
(
'SymLinkCategoryId'
);
if
(
is_null
(
$sym_category_id
))
{
return
false
;
}
$id_field
=
$this
->
Application
->
getUnitOption
(
$this
->
Prefix
,
'IDField'
);
$table_name
=
$this
->
Application
->
getUnitOption
(
$this
->
Prefix
,
'TableName'
);
$sql
=
'SELECT '
.
$id_field
.
'
FROM '
.
$table_name
.
'
WHERE '
.
$id_field
.
' = '
.
$sym_category_id
;
return
$this
->
Conn
->
GetOne
(
$sql
)?
true
:
false
;
}
/**
* Returns module prefix based on root category for given
*
* @param Array $params
* @return string
*/
function
GetModulePrefix
(
$params
)
{
$object
=&
$this
->
getObject
(
$params
);
/* @var $object kDBItem */
$parent_path
=
explode
(
'|'
,
substr
(
$object
->
GetDBField
(
'ParentPath'
),
1
,
-
1
));
$category_helper
=&
$this
->
Application
->
recallObject
(
'CategoryHelper'
);
/* @var $category_helper CategoryHelper */
$module_info
=
$category_helper
->
getCategoryModule
(
$params
,
$parent_path
);
return
$module_info
[
'Var'
];
}
}
?>
Event Timeline
Log In to Comment