Решение: Используем переменную сессии MODx mgrValidated. Она равна 1, если менеджер сайта авторизован.
Например:
<?php
return $_SESSION['mgrValidated']==1 ? $modx->getChunk('chunk-for-manager-only') : '';
?>
дневник Максима Коринца (yentsun), разработчика MODx (блог на данный момент не поддерживается)
<?php
return $_SESSION['mgrValidated']==1 ? $modx->getChunk('chunk-for-manager-only') : '';
?>
Include /usr/local/ispmgr/etc/ispmgr.inc
Alias /manager /usr/local/ispmgr/bin/
Меняем /manager на, скажем, /ispmanager и перезапускаем сервер. <?php
// ---------------------------------------------------
// Group: Filters
// Define custom or basic filters within the extender to expand Ditto's filtering capabilities
// ---------------------------------------------------
$filters["custom"]["exampleFilter"] = array("parent,artist_category","exampleFilter");
// Variable: $filters["custom"]["exampleFilter"]
// Add the filter exampleFilter to the custom filters
// list with the source pagetitle and the callback
// exampleFilter
if (!function_exists("exampleFilter")) {
// wrap functions in !function_exists statements to ensure that they are not defined twice
// ---------------------------------------------------
// Function: exampleFilter
//
// Takes the resource array for an individual document
// and asks for the return of a 0 or 1 with 0 removing
// the document and 1 leaving it in the result set.
// In this case, if the lower case value of the pagetitle
// is foo, it is removed while all other documents are shown
// ---------------------------------------------------
function exampleFilter($resource) {
global $modx;
$id = $modx->documentObject['id'];
if (!stristr($resource['artist_category'], $id) && $resource['parent'] != $id) {
return 0;
} else {
return 1;
}
}
}
?>
SELECT contentid, parent FROM modx_site_tmplvar_contentvalues JOIN modx_site_content ON modx_site_tmplvar_contentvalues.contentid = modx_site_content.id WHERE value = ".$output." AND tmplvarid = 5 AND parent IN ('4789','4794','4792') LIMIT 1
<?php
$query = "SELECT contentid, parent, pagetitle FROM modx_site_tmplvar_contentvalues JOIN modx_site_content ON modx_site_tmplvar_contentvalues.contentid = modx_site_content.id WHERE value = ".$output." AND tmplvarid = 5 AND parent IN ('4789','4794','4792') LIMIT 1";
$result = $modx->db->query($query);
$row = mysql_fetch_array($result);
$id = $row['contentid'];
return $id ? '<a class="news" title="Новости" href="[~4817~]?tags=[+pagetitle:name:common_name:url+]">Новости</a>' : '';
?>
if (!function_exists('setTemplateVar')) {
function setTemplateVar($value, $docID, $tplVarName) {
global $modx;
//-- get tmplvar id
$tplName = $modx->getFullTableName('site_tmplvars');
$tplRS = $modx->db->select('id', $tplName, 'name="' . $tplVarName . '"');
$tplRow = $modx->db->getRow($tplRS);
$tblName = $modx->getFullTableName('site_tmplvar_contentvalues');
$selectQuery = $modx->db->select('*', $tblName, 'contentid=' . $docID . ' AND tmplvarid=' . $tplRow['id']);
$updFields = array (
'value' => $value
);
$insFields = array (
'tmplvarid' => $tplRow['id'],
'contentid' => $docID,
'value' => $value
);
if ($modx->db->getRecordCount($selectQuery) < 1) {
$modx->db->insert($insFields, $tblName);
} else {
$modx->db->update($updFields, $tblName, 'contentid=' . $docID . ' AND tmplvarid=' . $tplRow['id']);
}
}
}
if(!isset($_SESSION['usertype'])) { $_SESSION['usertype'] = ''; }
if($modx->documentObject['donthit'] != 1 && $_SESSION['usertype'] != 'manager') {
$current = $modx->getTemplateVarOutput('count',$modx->documentIdentifier);
$current = $current['count']+1;
@ setTemplateVar("$current", $modx->documentIdentifier, 'count');
}
return;
<?php
// connect to database
$tb1 = $modx->getFullTableName("site_tmplvar_contentvalues");
$query = "SELECT value";
$query .= " FROM ".$tb1;
$query .= " WHERE tmplvarid=6";
$query .= " GROUP BY value";
$query .= " ORDER BY id DESC";
$query .= " LIMIT 100;";
$result = $modx->db->query($query);
// here we loop through the results and put them into a simple array:
while ($row = mysql_fetch_array($result)) {
$tags = explode(', ',$row['value']);
$tag_mess = array_merge($tag_mess, $tags);
}
// determine the font-size increment
// this is the increase per tag quantity (times used)
$tags = array_count_values($tag_mess);
arsort($tags);
$tags = array_slice($tags, 0, 30);
ksort($tags);
$max_qty = max(array_values($tags));
$min_qty = min(array_values($tags));
// change these font sizes if you will
$max_size = 200; // max font size in %
$min_size = 100; // min font size in %
// get the largest and smallest array values
// find the range of values
$spread = $max_qty - $min_qty;
if (0 == $spread) { // we don't want to divide by zero
$spread = 1;
}
$step = ($max_size - $min_size)/($spread);
// loop through our tag array
foreach ($tags as $key => $value) {
$size = $min_size + (($value - $min_qty) * $step);
$output .= '<a href="/[~4817~]?tags='.urlencode($key).'" style="font-size: '.$size.'%" title="">'.$key.'</a> ';
}
return $output;
?>