示例#1
0
}
//pr($searchResultsByType);
$resultsDatas = array();
$resultsDatas['results'] = array();
$resultsDatas['total'] = $count;
foreach ($searchResultsByType as $type => $results) {
    $items = array();
    switch ($type) {
        case 'rows':
            $rows = CMS_rowsCatalog::getAll(true, '', array(), array_keys($results));
            foreach ($rows as $row) {
                $items[] = $row->getJSonDescription($cms_user, $cms_language, false);
            }
            break;
        case 'templates':
            $tpls = CMS_pageTemplatesCatalog::getAll(true, '', array(), '', array_keys($results));
            foreach ($tpls as $tpl) {
                $items[] = $tpl->getJSonDescription($cms_user, $cms_language, false);
            }
            break;
        case 'users':
            $users = CMS_profile_usersCatalog::getAll(false, false, true, array('id_pru' => array_keys($results)));
            foreach ($users as $user) {
                $items[] = $user->getJSonDescription($cms_user, $cms_language, false);
            }
            break;
        case 'groups':
            $groups = CMS_profile_usersGroupsCatalog::search('', '', false, array_keys($results));
            foreach ($groups as $group) {
                $items[] = $group->getJSonDescription($cms_user, $cms_language, false);
            }
                 $pageTplIds = array(CMS_pageTemplatesCatalog::getTemplateIDForCloneID($pageTemplate->getID()));
             }
         }
     }
     if (io::isPositiveInteger($keyword)) {
         $pageTplIds[] = $keyword;
         $keyword = '';
     }
 } else {
     $pageTplIds = $items;
 }
 $templatesDatas = array();
 $templatesDatas['results'] = array();
 //get array of available templates
 $templates = CMS_pageTemplatesCatalog::getAll($viewinactive, $keyword, $groups, $website, $pageTplIds, $cms_user, $start, $limit);
 $templatesDatas['total'] = sizeof(CMS_pageTemplatesCatalog::getAll($viewinactive, $keyword, $groups, $website, $pageTplIds, $cms_user, 0, 0, false));
 foreach ($templates as $template) {
     if ($cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDIT_TEMPLATES)) {
         //templates
         if ($delete) {
             if (is_a($template, "CMS_pageTemplate") && !$template->hasPages()) {
                 $log = new CMS_log();
                 $log->logMiscAction(CMS_log::LOG_ACTION_TEMPLATE_DELETE, $cms_user, "Template : " . $template->getLabel());
                 if ($template->isPrivate()) {
                     $template->destroy();
                 } else {
                     //destroy with definition file
                     $template->destroy(true);
                 }
                 unset($template);
                 $templatesDatas['total']--;
示例#3
0
        list($sizeX, $sizeY) = @getimagesize($_SERVER["DOCUMENT_ROOT"] . "/" . $icon);
        $maxheight = $sizeY > $maxheight ? $sizeY : $maxheight;
    }
    $maxheight += 10;
    $columns = sizeof($allIcons) < 5 ? sizeof($allIcons) : 5;
    $iconsField .= "{\n\t\txtype: \t\t'radiogroup',\n\t\tfieldLabel: '<span class=\"atm-help\" ext:qtip=\"{$cms_language->getJsMessage(MESSAGE_FIELD_ICON_DESC)}\">{$cms_language->getJsMessage(MESSAGE_FIELD_ICON)}</span>',\n\t\tcolumns: \t{$columns},\n\t\titems: [";
    foreach ($allIcons as $icon) {
        $iconsField .= "{boxLabel: '<img src=\"{$icon}\">', height:" . $maxheight . ", inputValue:'{$icon}', name: 'image', checked:" . ($row->getImage() == $icon ? 'true' : 'false') . "},";
    }
    //remove last comma from groups
    $iconsField = io::substr($iconsField, 0, -1);
    $iconsField .= "\n\t\t]\n\t},";
}
//Templates filters
$filteredTemplates = $row->getFilteredTemplates();
$templates = CMS_pageTemplatesCatalog::getAll(true, '', array(), '', array(), $cms_user, 0, 0, true);
$availableTemplates = $selectedTemplates = array();
foreach ($templates as $id => $template) {
    if (in_array($id, $filteredTemplates)) {
        $selectedTemplates[] = array($id, $template->getLabel());
    } else {
        $availableTemplates[] = array($id, $template->getLabel());
    }
}
$availableTemplates = sensitiveIO::jsonEncode($availableTemplates);
$selectedTemplates = sensitiveIO::jsonEncode($selectedTemplates);
//DEFINITION TAB
$rowDefinition = $rowDefinition ? $rowDefinition : '<row></row>';
$content = '<textarea id="row-definition-' . $rowId . '" style="display:none;">' . htmlspecialchars($rowDefinition) . '</textarea>';
$view->setContent($content);
$title = sensitiveIO::sanitizeJSString(sensitiveIO::isPositiveInteger($rowId) ? $cms_language->getMessage(MESSAGE_PAGE_ROW) . ' ' . $label : $cms_language->getMessage(MESSAGE_PAGE_ROW_CREATE));
 /**
  * Get all templates replacement for a given template
  *
  * @param CMS_pageTemplate $tplFrom : the template to get replacements
  * @param CMS_profile_user $cms_user : user to get template replacements (to check rights)
  * @param integer $pageId : user to get template replacements (to check websites)
  * @return array : templates replacements array('match' => array(CMS_pageTemplate), 'nomatch' => array(CMS_pageTemplate));
  * @access public
  */
 static function getTemplatesReplacement($tplFrom, $user, $pageId = false)
 {
     if (!is_a($tplFrom, "CMS_pageTemplate")) {
         CMS_grandFather::raiseError('Template must be a valid CMS_pageTemplate object');
         return array('match' => array(), 'nomatch' => array());
     }
     //get website id if page id is provided
     $websiteId = '';
     if (sensitiveIO::isPositiveInteger($pageId)) {
         $page = CMS_tree::getPageByID($pageId);
         if ($page) {
             $website = $page->getWebsite();
             if ($website) {
                 $websiteId = $website->getID();
             }
         }
     }
     //All templates avalaibles for this user and page website
     $templatesReplacements = CMS_pageTemplatesCatalog::getAll(false, '', array(), $websiteId, array(), $user);
     $matchTpl = array();
     $notMatchTpl = array();
     //modules called in tplFrom
     $tplFromModules = $tplFrom->getModules();
     //clientSpaces in tplFrom
     $csFrom = $tplFrom->getClientSpacesTags();
     $oldClientSpaces = array();
     foreach ($csFrom as $tag) {
         $id = $tag->getAttribute("id") ? $tag->getAttribute("id") : 'NO ID';
         $oldClientSpaces[$tag->getAttribute("module")][] = $id;
     }
     //then check each templates
     foreach ($templatesReplacements as $tplTo) {
         $match = true;
         //remove templates wich not use same modules
         $tplToModules = $tplTo->getModules();
         if ($tplToModules != $tplFromModules) {
             $match = false;
         }
         //check for template number (must be greater or egual)
         if ($match) {
             $csTo = $tplTo->getClientSpacesTags();
             if (sizeof($csTo) < sizeof($csFrom)) {
                 $match = false;
             }
         }
         //search all tpl from in tpl to
         if ($match) {
             $newClientSpaces = array();
             foreach ($csTo as $tag) {
                 $id = $tag->getAttribute("id") ? $tag->getAttribute("id") : 'NO ID';
                 $newClientSpaces[$tag->getAttribute("module")][] = $id;
             }
             foreach ($oldClientSpaces as $module => $moduleCs) {
                 foreach ($moduleCs as $csId) {
                     //search id in from tpl
                     if (!isset($newClientSpaces[$module]) || !in_array($csId, $newClientSpaces[$module])) {
                         $match = false;
                     }
                 }
             }
         }
         if ($match) {
             //here templates match so add it to the array
             $matchTpl[] = $tplTo;
         } else {
             $notMatchTpl[] = $tplTo;
         }
     }
     //sort tables by template labels
     $sortfunc = create_function('$a,$b', 'return strnatcasecmp($a->getLabel(), $b->getLabel());');
     if ($sortfunc) {
         if ($matchTpl) {
             usort($matchTpl, $sortfunc);
         }
         if ($notMatchTpl) {
             usort($notMatchTpl, $sortfunc);
         }
     }
     //then return array of templates
     return array('match' => $matchTpl, 'nomatch' => $notMatchTpl);
 }