Cheetah
tags.inc.php
Go to the documentation of this file.
1 <?php
2 
8 require_once( 'header.inc.php' );
9 require_once( CH_DIRECTORY_PATH_INC . 'db.inc.php' );
10 require_once( CH_DIRECTORY_PATH_INC . 'design.inc.php' );
11 require_once( CH_DIRECTORY_PATH_INC . 'profiles.inc.php' );
12 require_once( CH_DIRECTORY_PATH_INC . 'utils.inc.php' );
13 require_once( CH_DIRECTORY_PATH_CLASSES . 'ChWsbTags.php' );
14 
15 function explodeTags( $text )
16 {
17  //$text = preg_replace( '/[^a-zA-Z0-9_\'-]/', ' ', $text );
18 
19  $aTags = preg_split( '/[' . CH_WSB_TAGS_DIVIDER . ']/', $text, 0, PREG_SPLIT_NO_EMPTY );
20 
21  foreach( $aTags as $iInd => $sTag ) {
22  if( strlen( $sTag ) < 3 )
23  unset( $aTags[$iInd] );
24  else
25  $aTags[$iInd] = trim(mb_strtolower( $sTag , 'UTF-8'));
26  }
27  $aTags = array_unique( $aTags );
28  $sTagsNotParsed = getParam( 'tags_non_parsable' );
29  $aTagsNotParsed = preg_split( '/[' . CH_WSB_TAGS_DIVIDER . ']/', $sTagsNotParsed, 0, PREG_SPLIT_NO_EMPTY );
30 
31  $aTags = array_diff( $aTags, $aTagsNotParsed ); //drop non parsable tags
32 
33  return $aTags;
34 }
35 
36 function storeTags( $iID, $sTags, $sType )
37 {
38  $aTags = explodeTags( $sTags );
39  db_res( "DELETE FROM `sys_tags` WHERE `ID` = ? AND `Type` = ?", [$iID, $sType]); //re-store if exist
40 
41  foreach( $aTags as $sTag ) {
42  $sTag = addslashes( $sTag );
43  db_res( "INSERT INTO `sys_tags` VALUES ( ?, ?, ?, CURRENT_TIMESTAMP )", [$sTag, $iID, $sType]);
44  }
45 }
46 
47 function reparseObjTags( $sType, $iID )
48 {
49  $oTags = new ChWsbTags();
50  $oTags->reparseObjTags($sType, $iID);
51 }
explodeTags
explodeTags( $text)
Definition: tags.inc.php:15
CH_WSB_TAGS_DIVIDER
const CH_WSB_TAGS_DIVIDER
Definition: ChWsbTags.php:12
php
ChWsbTags
Definition: ChWsbTags.php:15
$sType
$sType
Definition: actions.inc.php:11
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
$sTags
$sTags
Definition: actions.inc.php:12
storeTags
storeTags( $iID, $sTags, $sType)
Definition: tags.inc.php:36
db_res
db_res($query, $bindings=[])
Definition: db.inc.php:39
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
reparseObjTags
reparseObjTags( $sType, $iID)
Definition: tags.inc.php:47