Здоровье
// check that we have access
defined( '_VALID_MOS' ) or die( 'Restricted access' );
// register our event. It would be great of joomla had more events
$_MAMBOTS->registerFunction( 'onPrepareContent', 'JoomSEO' );
function JoomSEO($published, &$row, &$params, $page=0) {
global $database, $mainframe, $mosConfig_MetaKeys, $mosConfig_MetaDesc, $mosConfig_sitename;
// perform a published check
if (!$published) {
return;
}
// get our bot parameters
$query = "SELECT id FROM #__mambots WHERE element = 'JoomSEO' AND folder = 'content'";
$database->setQuery($query);
$id = $database->loadResult();
// get our mambot object
$mambot = new mosMambot($database);
$mambot->load($id);
$botParams = new mosParameters($mambot->params);
// load all our vars
//Title
$titleLength = $botParams->get('titleLength', false);
$titleOrder = $botParams->get('titleOrder', 1);
$prependTitle = $botParams->get('prependTitle', false);
$appendTitle = $botParams->get('appendTitle', false);
// site name
$showTitleSiteName = $botParams->get('showTitleSiteName', true);
$overrideSiteName = $botParams->get('overrideSiteName', false);
// content / heading title
$showContentHeading = $botParams->get('showContentHeading', true);
// paragraph
$showFirstParagraph = $botParams->get('showFirstParagraph', false);
$paragraphMinLength = $botParams->get('paragraphMinLength', 20);
$paragraphLength = $botParams->get('paragraphLength', 50);
// keywords
$showTitleKeywords = $botParams->get('showTitleKeywords', true);
$overrideTitleKeywords = $botParams->get('overrideTitleKeywords', false);
$keywordMinCharacters = $botParams->get('keywordMinCharacters', 3);
$titleKeywordQuantity = $botParams->get('titleKeywordQuantity', 5);
// meta
$metaKeywordsCount = $botParams->get('metaKeywordsCount', 50);
$metaDescriptionMinLength = $botParams->get('metaDescriptionMinLength', 80);
$metaDescriptionLength = $botParams->get('metaDescriptionLength', 150);
// filter
// when bot was first installed these were not being added unless bot was *saved*
$defStickWords = "";
$stickyWords = $botParams->get('stickyWords', $defStickWords);
$defBadWords = "0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z about an are as at be by com de en for from how in is it its la of on or that the this to was what when where who will with und the www and all has been your us up youll can if youve do know we not many you our but there they then more";
$badWords = $botParams->get('badWords', $defBadWords);
$defBadCharacters = "0 1 2 3 4 5 6 7 8 9 > < & - , . ; : ) ( ? ! { } [ ] / ' " %";
$badCharacters = $botParams->get('badCharacters', $defBadCharacters);
// bot activation
$disableFrontpage = $botParams->get('disableFrontpage', false);
// activation specific
$disableFrontpageTitle = $botParams->get('disableFrontpageTitle', false);
$disableFrontpageKeywords = $botParams->get('disableFrontpageKeywords', false);
$disableFrontpageDescription = $botParams->get('disableFrontpageDescription', false);
// front page overrides. Front page or corresponding item must be enabled though
$overrideFrontPageTitle = $botParams->get('overrideFrontPageTitle', false);
$overrideFrontPageKeywords = $botParams->get('overrideFrontPageKeywords', false);
$overrideFrontPageDescription = $botParams->get('overrideFrontPageDescription', false);
// SEO / Accessability
// defaulted to false to as not to break existing templates
$addHeadingTags = $botParams->get('addHeadingTags', false);
// current settings
$currentTitle = gettitle();
$currentContentHeading = $row->title;
$currentMetaKeys = $mosConfig_MetaKeys;
$currentMetaDesc = $mosConfig_MetaDesc;
// added to limit sql queries
$isFrontPage = IsFrontPage();
// firstly add our generator tag.
// please leave this here as it will not affect seo
// and gives my countless hours of programming an idea of use.
global $beenHere;
if (!$beenHere) {
// add JoomSEO bot to Generator meta
ReplaceMeta('Generator', ' JoomSEO by Phill Brown (http://www.joomseo.com).');
}
// encompass our headings with hX tags
// added first as we want this active even if the front page is disabled
if ($addHeadingTags) {
$row->title = AddHeadingTags($row->title, $addHeadingTags);
}
// check if we are enabled on the front page
if (($isFrontPage) && ($disableFrontpage)) {
// removed after added front page overrides and specific disabled attributes
// were added after release 0.9
//if ($disabledFrontPageTitle) {
// apply replacement text instead of joomla default
// replacetitle($disabledFrontPageTitle);
//}
// exit from this bot
return;
}
// clean and organise our text
$text = PrepareText($row->text);
// all CleanChars() no longer used as it was stopping other languages from operating proplerly
//$text = CleanChars($text);
$stickyWords = PrepareText($stickyWords);
//$stickyWords = CleanChars($stickyWords);
$badWords = PrepareText($badWords);
//$badWords = CleanChars($badWords);
$badCharacters = PrepareText($badCharacters);
//$badCharacters = CleanChars($badCharacters);
// clear existing meta keywords and descriptions
$mosConfig_MetaKeys = "";
$mosConfig_MetaDesc = "";
// was thinking of adding later a check to use only first article or all articles
// this get the total content from all articles from a com_frontpage
global $botSefText;
$botSefText .= $text;
// get our site name
// added to get the site title once
global $newSiteName;
//$newSiteName = null;
if (!$newSiteName) {
if ($showTitleSiteName) {
$newSiteName = $mosConfig_sitename;
if ($overrideSiteName) {
$newSiteName = $overrideSiteName;
}
}
}
// get our content heading
// added this to get first heading
global $newContentHeading;
//$newContentHeading = null;
if (!$newContentHeading) {
if ($showContentHeading) {
$newContentHeading = $currentContentHeading;
}
}
// get our first paragraph
// added to get the paragraph once only
global $newFirstParagraph;
//$newFirstParagraph = null;
if (!$newFirstParagraph) {
if ($showFirstParagraph) {
$newFirstParagraph = trim(GetDescription($botSefText, $paragraphMinLength, $paragraphLength));
}
}
// get our title keywords
// no global as we need this to parse all keywords
$newTitleKeywords = null;
if ($showTitleKeywords) {
$newTitleKeywords = GlueItems(GetKeywords($botSefText,$keywordMinCharacters,$titleKeywordQuantity,$stickyWords,$badWords,$badCharacters));
if ($overrideTitleKeywords) {
$newTitleKeywords = GlueItems(GetKeywords($overrideTitleKeywords));
}
}
// sort our title
$titleArray = array();
Push($titleArray, $prependTitle);
switch ($titleOrder) {
case 1://
Push($titleArray, $newSiteName);
if ($newContentHeading != null) {
Push($titleArray, ($newFirstParagraph) ? $newContentHeading ." - ". $newFirstParagraph : $newContentHeading);
} else {
Push($titleArray, $newFirstParagraph);
}
Push($titleArray, $newTitleKeywords);
break;
case 2://
Push($titleArray, $newSiteName);
Push($titleArray, $newTitleKeywords);
if ($newContentHeading != null) {
Push($titleArray, ($newFirstParagraph) ? $newContentHeading ." - ". $newFirstParagraph : $newContentHeading);
} else {
Push($titleArray, $newFirstParagraph);
}
break;
case 3://
if ($newContentHeading != null) {
Push($titleArray, ($newFirstParagraph) ? $newContentHeading ." - ". $newFirstParagraph : $newContentHeading);
} else {
Push($titleArray, $newFirstParagraph);
}
Push($titleArray, $newSiteName);
Push($titleArray, $newTitleKeywords);
break;
case 4://
if ($newContentHeading != null) {
Push($titleArray, ($newFirstParagraph) ? $newContentHeading ." - ". $newFirstParagraph : $newContentHeading);
} else {
Push($titleArray, $newFirstParagraph);
}
Push($titleArray, $newTitleKeywords);
Push($titleArray, $newSiteName);
break;
case 5://
Push($titleArray, $newTitleKeywords);
Push($titleArray, $newSiteName);
if ($newContentHeading != null) {
Push($titleArray, ($newFirstParagraph) ? $newContentHeading ." - ". $newFirstParagraph : $newContentHeading);
} else {
Push($titleArray, $newFirstParagraph);
}
break;
case 6://
Push($titleArray, $newTitleKeywords);
if ($newContentHeading != null) {
Push($titleArray, ($newFirstParagraph) ? $newContentHeading ." - ". $newFirstParagraph : $newContentHeading);
} else {
Push($titleArray, $newFirstParagraph);
}
Push($titleArray, $newSiteName);
break;
}
Push($titleArray, $appendTitle);
if ($titleLength) {
$newTitle = substr(implode(' | ', $titleArray),0,$titleLength);
} else {
$newTitle = implode(' | ', $titleArray);
}
// its the front page so do front page specific handling
if ($isFrontPage) {
// get our frontpage title
if ($disableFrontpageTitle) {
// use the joomla generated title
$newTitle = $currentTitle;
} else {
$newTitle = ($overrideFrontPageTitle) ? $overrideFrontPageTitle : $newTitle;
}
// get our frontpage keywords
if ($disableFrontpageKeywords) {
// use the joomla default
$metaKeywords = $currentMetaKeys;
} else {
$metaKeywords = ($overrideFrontPageKeywords) ? $overrideFrontPageKeywords : GlueItems(GetKeywords($botSefText,$keywordMinCharacters,$metaKeywordsCount,$stickyWords,$badWords,$badCharacters));
}
// get our frontpage description
if ($disableFrontpageDescription) {
// use the joomla default
$metaDescription = $currentMetaDesc;
} else {
$metaDescription = ($overrideFrontPageDescription) ? $overrideFrontPageDescription : GetDescription($botSefText, $metaDescriptionMinLength, $metaDescriptionLength);
}
} else {
// we are on any other page so perform normal operations
$metaKeywords = GlueItems(GetKeywords($botSefText,$keywordMinCharacters,$metaKeywordsCount,$stickyWords,$badWords,$badCharacters));
$metaDescription = GetDescription($botSefText, $metaDescriptionMinLength, $metaDescriptionLength);
}
replacetitle($newTitle);
ReplaceMeta('keywords', $metaKeywords);
ReplaceMeta('description', $metaDescription);
// set our been here status
$beenHere = true;
}
/**
* Add an item to our array
*
* @param array $stack
* @param text $var
*/
function Push(&$stack, $var) {
if ($var) {
array_push($stack, $var);
}
}
/**
* Add H1, H2, H3... tags to text
*
* @param string $title
* @param int $num
* @return string
*/
function AddHeadingTags($title, $num) {
return " "; //} return $ret; } /** * Clean and prepare text, remove any unwanted tags etc * * @param string $text * @return string */ function PrepareText($text) { // removed as redundant from strip_tags // and was causing parsing problems due to incorrect regex. // regex is fixed for the sake of being fixed. // convert html br to space /*$regex = '/(
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Далее...
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| << [Первая] < [Предыдущая] 1 2 [Следующая] > [Последняя] >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Результаты 1 - 9 из 13 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||









Рецепт простой, но проконсультируйтесь со врачом.