dolibarr  19.0.0-dev
Functions
website.lib.php File Reference

Library for website module. More...

Go to the source code of this file.

Functions

 dolStripPhpCode ($str, $replacewith='')
 Remove PHP code part from a string. More...
 
 dolKeepOnlyPhpCode ($str)
 Keep only PHP code part from a HTML string page. More...
 
 dolWebsiteReplacementOfLinks ($website, $content, $removephppart=0, $contenttype='html', $containerid='')
 Convert a page content to have correct links (based on DOL_URL_ROOT) into an html content. More...
 
 dolReplaceSmileyCodeWithUTF8 ($content)
 Converts smiley string into the utf8 sequence. More...
 
 dolWebsiteOutput ($content, $contenttype='html', $containerid='')
 Render a string of an HTML content and output it. More...
 
 dolWebsiteIncrementCounter ($websiteid, $websitepagetype, $websitepageid)
 Increase the website counter of page access. More...
 
 redirectToContainer ($containerref, $containeraliasalt='', $containerid=0, $permanent=0)
 Format img tags to introduce viewimage on img src. More...
 
 includeContainer ($containerref)
 Clean an HTML page to report only content, so we can include it into another page. More...
 
 getStructuredData ($type, $data=array())
 Return HTML content to add structured data for an article, news or Blog Post. More...
 
 getSocialNetworkHeaderCards ($params=null)
 Return HTML content to add as header card for an article, news or Blog Post or home page. More...
 
 getSocialNetworkSharingLinks ()
 Return HTML content to add structured data for an article, news or Blog Post. More...
 
 getPagesFromSearchCriterias ($type, $algo, $searchstring, $max=25, $sortfield='date_creation', $sortorder='DESC', $langcode='', $otherfilters='null', $status=1)
 Return list of containers object that match a criteria. More...
 
 getAllImages ($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks=0, $grabimages=1, $grabimagesinto='subpage')
 Download all images found into page content $tmp. More...
 

Detailed Description

Library for website module.

Definition in file website.lib.php.

Function Documentation

◆ dolKeepOnlyPhpCode()

dolKeepOnlyPhpCode (   $str)

Keep only PHP code part from a HTML string page.

Parameters
string$strString to clean
Returns
string Result string with php code only
See also
dolStripPhpCode(), checkPHPCode()

Definition at line 76 of file website.lib.php.

◆ dolReplaceSmileyCodeWithUTF8()

dolReplaceSmileyCodeWithUTF8 (   $content)

Converts smiley string into the utf8 sequence.

Parameters
string$contentContent to replace
Returns
string Replacement of all smiley strings with their utf8 code
See also
dolWebsiteOutput()

Definition at line 226 of file website.lib.php.

◆ dolStripPhpCode()

dolStripPhpCode (   $str,
  $replacewith = '' 
)

Remove PHP code part from a string.

Parameters
string$strString to clean
string$replacewithString to use as replacement
Returns
string Result string without php code
See also
dolKeepOnlyPhpCode()

Definition at line 32 of file website.lib.php.

◆ dolWebsiteIncrementCounter()

dolWebsiteIncrementCounter (   $websiteid,
  $websitepagetype,
  $websitepageid 
)

Increase the website counter of page access.

Parameters
int$websiteidID of website
string$websitepagetypeType of page ('blogpost', 'page', ...)
int$websitepageidID of page
Returns
int <0 if KO, >0 if OK

Definition at line 438 of file website.lib.php.

◆ dolWebsiteOutput()

dolWebsiteOutput (   $content,
  $contenttype = 'html',
  $containerid = '' 
)

Render a string of an HTML content and output it.

Used to ouput the page when viewed from a server (Dolibarr or Apache).

Parameters
string$contentContent string
string$contenttypeContent type
int$containeridContenair id
Returns
void
See also
dolWebsiteReplacementOfLinks() for function used to replace content in the backoffice context.

Definition at line 277 of file website.lib.php.

◆ dolWebsiteReplacementOfLinks()

dolWebsiteReplacementOfLinks (   $website,
  $content,
  $removephppart = 0,
  $contenttype = 'html',
  $containerid = '' 
)

Convert a page content to have correct links (based on DOL_URL_ROOT) into an html content.

It replaces also dynamic content with '...php...' Used to ouput the page on the Preview from backoffice.

Parameters
Website$websiteWeb site object
string$contentContent to replace
int$removephppart0=Replace PHP sections with a PHP badge. 1=Remove completely PHP sections.
string$contenttypeContent type
int$containeridContenair id
Returns
boolean True if OK
See also
dolWebsiteOutput() for function used to replace content in a web server context

Definition at line 118 of file website.lib.php.

◆ getAllImages()

getAllImages (   $object,
  $objectpage,
  $urltograb,
$tmp,
$action,
  $modifylinks = 0,
  $grabimages = 1,
  $grabimagesinto = 'subpage' 
)

Download all images found into page content $tmp.

If $modifylinks is set, links to images will be replace with a link to viewimage wrapper.

Parameters
Website$objectObject website
WebsitePage$objectpageObject website page
string$urltograbURL to grab (exemple: http://www.nltechno.com/ or http://www.nltechno.com/dir1/ or http://www.nltechno.com/dir1/mapage1)
string$tmpContent to parse
string$actionVar $action
string$modifylinks0=Do not modify content, 1=Replace links with a link to viewimage
int$grabimages0=Do not grab images, 1=Grab images
string$grabimagesinto'root' or 'subpage'
Returns
void

Definition at line 1144 of file website.lib.php.

◆ getPagesFromSearchCriterias()

getPagesFromSearchCriterias (   $type,
  $algo,
  $searchstring,
  $max = 25,
  $sortfield = 'date_creation',
  $sortorder = 'DESC',
  $langcode = '',
  $otherfilters = 'null',
  $status = 1 
)

Return list of containers object that match a criteria.

WARNING: This function can be used by websites.

Parameters
string$typeType of container to search into (Example: '', 'page', 'blogpost', 'page,blogpost', ...)
string$algoAlgorithm used for search (Example: 'meta' is searching into meta information like title and description, 'content', 'sitefiles', or any combination 'meta,content,...')
string$searchstringSearch string
int$maxMax number of answers
string$sortfieldSort Fields
string$sortorderSort order ('DESC' or 'ASC')
string$langcodeLanguage code ('' or 'en', 'fr', 'es', ...)
array$otherfiltersOther filters
int$status0 or 1, or -1 for both
Returns
array Array with results of search

Definition at line 979 of file website.lib.php.

◆ getSocialNetworkHeaderCards()

getSocialNetworkHeaderCards (   $params = null)

Return HTML content to add as header card for an article, news or Blog Post or home page.

Parameters
array$paramsArray of parameters
Returns
string HTML content

Definition at line 836 of file website.lib.php.

◆ getSocialNetworkSharingLinks()

getSocialNetworkSharingLinks ( )

Return HTML content to add structured data for an article, news or Blog Post.

Returns
string HTML content

Definition at line 910 of file website.lib.php.

◆ getStructuredData()

getStructuredData (   $type,
  $data = array() 
)

Return HTML content to add structured data for an article, news or Blog Post.

Use the json-ld format. Example: <?php getStructureData('blogpost'); ?> <?php getStructureData('software', array('name'=>'Name', 'os'=>'Windows', 'price'=>10)); ?>

Parameters
string$type'blogpost', 'product', 'software', 'organization', 'qa', ...
array$dataArray of data parameters for structured data
Returns
string HTML content

Definition at line 631 of file website.lib.php.

◆ includeContainer()

includeContainer (   $containerref)

Clean an HTML page to report only content, so we can include it into another page.

It outputs content of file sanitized from html and body part.

Parameters
string$containerrefPath to file to include (must be a page from website root. Example: 'mypage.php' means 'mywebsite/mypage.php')
Returns
void

Definition at line 577 of file website.lib.php.

◆ redirectToContainer()

redirectToContainer (   $containerref,
  $containeraliasalt = '',
  $containerid = 0,
  $permanent = 0 
)

Format img tags to introduce viewimage on img src.

Parameters
string$contentContent string
Returns
void
See also
dolWebsiteOutput() Make a redirect to another container.
Parameters
string$containerrefRef of container to redirect to (Example: 'mypage' or 'mypage.php').
string$containeraliasaltRef of alternative aliases to redirect to.
int$containeridId of container.
int$permanent0=Use temporary redirect 302, 1=Use permanent redirect 301
Returns
void

Definition at line 501 of file website.lib.php.