function ddGetDocs($parentIds = array(0), $filter = array(), $depth = 1, $labelMask = '[+pagetitle+] ([+id+])', $fields = array('pagetitle', 'id'))
 {
     //Получаем дочерние документы текущего уровня
     $docs = array();
     //Перебираем всех родителей
     foreach ($parentIds as $parent) {
         //Получаем документы текущего родителя
         $tekDocs = ddTools::getDocumentChildrenTVarOutput($parent, $fields, false);
         //Если что-то получили
         if (is_array($tekDocs)) {
             //Запомним
             $docs = array_merge($docs, $tekDocs);
         }
     }
     $result = array();
     //Если что-то есть
     if (count($docs) > 0) {
         //Перебираем полученные документы
         foreach ($docs as $val) {
             //Если фильтр пустой, либо не пустой и документ удовлетворяет всем условиям
             if (empty($filter) || count(array_intersect_assoc($filter, $val)) == count($filter)) {
                 $val['title'] = empty($val['menutitle']) ? $val['pagetitle'] : $val['menutitle'];
                 //Записываем результат
                 $tmp = ddTools::parseText($labelMask, $val, '[+', '+]', false);
                 if (strlen(trim($tmp)) == 0) {
                     $tmp = ddTools::parseText('[+pagetitle+] ([+id+])', $val, '[+', '+]', false);
                 }
                 $result[] = array('label' => $tmp, 'value' => $val['id']);
             }
             //Если ещё надо двигаться глубже
             if ($depth > 1) {
                 //Сливаем результат с дочерними документами
                 $result = array_merge($result, ddGetDocs(array($val['id']), $filter, $depth - 1, $labelMask, $fields));
             }
         }
     }
     return $result;
 }
Example #2
0
    include_once $richtextIncludeDirectory . 'assets/cache/siteManager.php';
}
if (!defined('MGR_DIR')) {
    define('MGR_DIR', 'manager');
}
$richtextIncludeDirectory .= MGR_DIR . '/';
//Config
$_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME'] = '/';
require_once $richtextIncludeDirectory . 'includes/protect.inc.php';
require_once $richtextIncludeDirectory . 'includes/config.inc.php';
startCMSSession();
if ($_SESSION['mgrValidated']) {
    define('IN_MANAGER_MODE', true);
    //Setup the MODx API
    define('MODX_API_MODE', true);
    //Initiate a new document parser
    require_once $richtextIncludeDirectory . 'includes/document.parser.class.inc.php';
    $modx = new DocumentParser();
    //Provide the MODx DBAPI
    $modx->db->connect();
    //Provide the $modx->documentMap and user settings
    $modx->getSettings();
    $mmDir = 'assets/plugins/managermanager/';
    $windowDir = $mmDir . 'widgets/ddmultiplefields/richtext/';
    //Include the ddTools library
    require_once $modx->config['base_path'] . $mmDir . 'modx.ddtools.class.php';
    $temp = $modx->invokeEvent('OnRichTextEditorInit', array('editor' => 'TinyMCE', 'elements' => array('ddMultipleFields_richtext')));
    echo ddTools::parseText(file_get_contents($modx->config['base_path'] . $windowDir . 'template.html'), array('site_url' => $modx->config['site_url'], 'mmDir' => $mmDir, 'windowDir' => $windowDir, 'charset' => '<meta charset="' . $modx->config['modx_charset'] . '" />', 'style' => MODX_MANAGER_URL . 'media/style/' . $modx->config['manager_theme'] . '/style.css', 'tinyMCE' => $temp[0]), '[+', '+]', false);
} else {
    echo file_get_contents(dirname(__FILE__) . '/index.html');
}