function showAddTemplatePeekAction() { @($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id'], 'string', '')); @($portal = DevblocksPlatform::importGPC($_REQUEST['portal'], 'string', '')); $tpl = DevblocksPlatform::getTemplateService(); $tpl->assign('path', $this->_TPL_PATH); $tpl->assign('view_id', $view_id); $tpl->assign('portal', $portal); if (null == ($tool = DAO_CommunityTool::getByCode($portal))) { return; } if (null == ($tool_ext = DevblocksPlatform::getExtension($tool->extension_id, false))) { return; } if (null == ($template_set = @$tool_ext->params['template_set'])) { $template_set = ''; } // not null $templates = DevblocksPlatform::getTemplates($template_set); $existing_templates = DAO_DevblocksTemplate::getWhere(sprintf("%s = %s", DAO_DevblocksTemplate::TAG, C4_ORMHelper::qstr('portal_' . $portal))); // Sort templates uasort($templates, create_function('$a, $b', "return strcasecmp(\$a->plugin_id.' '.\$a->path,\$b->plugin_id.' '.\$b->path);\n")); // Filter out templates implemented by this portal already if (is_array($templates)) { foreach ($templates as $idx => $template) { /* @var $template DevblocksTemplate */ if (is_array($existing_templates)) { foreach ($existing_templates as $existing) { /* @var $existing Model_DevblocksTemplate */ if (0 == strcasecmp($template->plugin_id, $existing->plugin_id) && 0 == strcasecmp($template->path, $existing->path)) { unset($templates[$idx]); } } } } } $tpl->assign('templates', $templates); $tpl->display('file:' . $this->_TPL_PATH . 'community/display/tabs/templates/add.tpl'); }