Решение: Используем переменную сессии 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;
?>
/*
* Inherit Template from Parent
* Written By Raymond Irving - 12 Oct 2006
*
* Simply results in new documents inherriting the template
* of their parent folder upon creating a new document
*
* Configuration:
* check the OnDocFormPrerender event
*
* Version 1.0
*
*/
global $content;
$e = &$modx->Event;
$parents_and_templates = array (
'4818' => '5', // id родителя => id шаблона (можно посмотреть в БД)
'4817' => '6'
);
switch($e->name) {
case 'OnDocFormPrerender':
if(($_REQUEST['pid'] > 0) && ($id == 0)) {
$parent = $modx->getPageInfo($_REQUEST['pid'],0,'id, parent, template');
$parent = $modx->getPageInfo($parent['parent'],0,'id, parent, template'); //закомментируйте эту строку, если вам нужен родитель первого уровня
$pid = $parent['id'];
if (array_key_exists($pid,$parents_and_templates)) {
$content['template'] = $parents_and_templates[$pid];
}
else {
$content['template'] = $parent['template'];
}
}
break;
default:
return;
break;
}
$parents_and_templates = array (
'4818' => '5',
'4817' => '6'
);
// retain form values if template was changed
// edited to convert pub_date and unpub_date
// sottwell 02-09-2006
if ($formRestored == true || isset ($_REQUEST['newtemplate'])) {
$content = array_merge($content, $_POST);
$content["content"] = $_POST["ta"];
if (empty ($content["pub_date"])) {
unset ($content["pub_date"]);
} else {
$pub_date = $content['pub_date'];
list ($d, $m, $Y, $H, $M, $S) = sscanf($pub_date, "%2d-%2d-%4d %2d:%2d:%2d");
$pub_date = strtotime("$m/$d/$Y $H:$M:$S");
$content['pub_date'] = $pub_date;
}
if (empty ($content["unpub_date"])) {
unset ($content["unpub_date"]);
} else {
$unpub_date = $content['unpub_date'];
list ($d, $m, $Y, $H, $M, $S) = sscanf($unpub_date, "%2d-%2d-%4d %2d:%2d:%2d");
$unpub_date = strtotime("$m/$d/$Y $H:$M:$S");
$content['unpub_date'] = $unpub_date;
}
}
на // retain form values if template was changed
// edited to convert pub_date and unpub_date
// sottwell 02-09-2006
if ($formRestored == true || isset ($_REQUEST['newtemplate'])) {
$content = array_merge($content, $_POST);
$content["content"] = $_POST["ta"];
if (empty ($content["pub_date"])) {
unset ($content["pub_date"]);
} else {
$pub_date = $content['pub_date'];
list ($d, $m, $Y, $H, $M, $S) = sscanf($pub_date, "%2d-%2d-%4d %2d:%2d:%2d");
$pub_date = strtotime("$m/$d/$Y $H:$M:$S");
$content['pub_date'] = $pub_date;
}
if (empty ($content["unpub_date"])) {
unset ($content["unpub_date"]);
} else {
$unpub_date = $content['unpub_date'];
list ($d, $m, $Y, $H, $M, $S) = sscanf($unpub_date, "%2d-%2d-%4d %2d:%2d:%2d");
$unpub_date = strtotime("$m/$d/$Y $H:$M:$S");
$content['unpub_date'] = $unpub_date;
}
if (empty ($content["createdon"])) {
unset ($content["createdon"]);
} else {
$createdon = $content['createdon'];
list ($d, $m, $Y, $H, $M, $S) = sscanf($createdon, "%2d-%2d-%4d %2d:%2d:%2d");
$createdon = strtotime("$m/$d/$Y $H:$M:$S");
$content['createdon'] = $createdon;
}
}
<tr>
<td><span class="warning">Дата создания</span></td>
<td>
<?php
$timestamp = time();
?>
<input name="createdon" value="<?php echo $content['createdon']=="0" || !isset($content['createdon']) ? strftime("%d-%m-%Y %H:%M:%S", $timestamp) : strftime("%d-%m-%Y %H:%M:%S", $content['createdon']); ?>" onblur="documentDirty=true;" />
<a onclick="documentDirty=false; cal0.popup();" onmouseover="window.status='<?php echo $_lang['select_date']; ?>'; return true;" onmouseout="window.status=''; return true;" style="cursor:pointer; cursor:hand"><img src="media/style/<?php echo $manager_theme ? "$manager_theme/":""; ?>images/icons/cal.gif" width="16" height="16" border="0" alt="<?php echo $_lang['select_date']; ?>" /></a>
</td>
</tr>
<script type="text/javascript">
... следующий код: var cal0 = new calendar1(document.forms['mutate'].elements['createdon'], document.getElementById("pub_date_show"));
cal0.path="<?php echo str_replace("index.php", "media/", $_SERVER["PHP_SELF"]); ?>";
cal0.year_scroll = true;
cal0.time_comp = true;
$createdon = $_POST['createdon'];
list ($d, $m, $Y, $H, $M, $S) = sscanf($createdon, "%2d-%2d-%4d %2d:%2d:%2d"); //added by yentsun
$createdon = mktime($H, $M, $S, $m, $d, $Y);
$sql = "INSERT INTO $tblsc (introtext,content, pagetitle, longtitle, type, description, alias, link_attributes, isfolder, richtext, published, parent, template, menuindex, searchable, cacheable, createdby, createdon, editedby, editedon, publishedby, publishedon, pub_date, unpub_date, contentType, content_dispo, donthit, menutitle, hidemenu)
VALUES('" . $introtext . "','" . $content . "', '" . $pagetitle . "', '" . $longtitle . "', '" . $type . "', '" . $description . "', '" . $alias . "', '" . $link_attributes . "', '" . $isfolder . "', '" . $richtext . "', '" . $published . "', '" . $parent . "', '" . $template . "', '" . $menuindex . "', '" . $searchable . "', '" . $cacheable . "', '" . $modx->getLoginUserID() . "', " . $createdon . ", '" . $modx->getLoginUserID() . "', " . time() . ", " . $publishedby . ", " . $publishedon . ", '$pub_date', '$unpub_date', '$contentType', '$contentdispo', '$donthit', '$menutitle', '$hidemenu')";
, блок $sql = "UPDATE $tblsc SET introtext='$introtext', content='$content', pagetitle='$pagetitle', longtitle='$longtitle', type='$type', description='$description', alias='$alias', link_attributes='$link_attributes',
isfolder=$isfolder, richtext=$richtext, published=$published, pub_date=$pub_date, unpub_date=$unpub_date, parent=$parent, template=$template, menuindex='$menuindex',
searchable=$searchable, cacheable=$cacheable, editedby=" . $modx->getLoginUserID() . ", editedon=" . time() . ", publishedon=$publishedon, publishedby=$publishedby, contentType='$contentType', content_dispo='$contentdispo', donthit='$donthit', menutitle='$menutitle', hidemenu='$hidemenu' WHERE id=$id;";
на $sql = "UPDATE $tblsc SET introtext='$introtext', content='$content', pagetitle='$pagetitle', longtitle='$longtitle', type='$type', description='$description', alias='$alias', link_attributes='$link_attributes',
isfolder=$isfolder, richtext=$richtext, published=$published, pub_date=$pub_date, unpub_date=$unpub_date, parent=$parent, template=$template, menuindex='$menuindex',
searchable=$searchable, cacheable=$cacheable, editedby=" . $modx->getLoginUserID() . ", editedon=" . time() . ", publishedon=$publishedon, publishedby=$publishedby, contentType='$contentType', content_dispo='$contentdispo', donthit='$donthit', menutitle='$menutitle', hidemenu='$hidemenu', createdon='$createdon' WHERE id=$id;";
(добавляем в хвост запроса строку createdon='$createdon')
$options = explode('|', $options);
$delimiter = (!empty($options[0])) ? $options[0] : ', ';
$links_limit = (!empty($options[1])) ? $options[1] : 3;
$url = $options[2];
$links_class = (!empty($options[3])) ? $options[3] : 'tag_link';
$array = explode($delimiter, $output);
$tail = (count($array)>$links_limit) ? '...' : '';
for ($i=0; $i<=$links_limit-1; $i++) {
$retval .= '<a class="'.$links_class.'" href="[(base_url)]'.$url.'?tags='.urlencode($array[$i]).'">'.$array[$i].'</a>';
}
return $retval.$tail;
mysql_select_db($dbase);
mysql_query("SET NAMES 'utf8';",$modxDBConn);
mysql_query("SET CHARACTER SET 'utf8';",$modxDBConn);
mysql_query("SET SESSION collation_connection = 'utf8_general_ci';",$modxDBConn);
В некоторых случаях придется сделать похожие изменения и в файле manager/includes/extenders/dbapi.mysql.class.inc.php около 90 строки (см. сообщение в форуме)