static function get_timestamp($tpl_name, &$tpl_timestamp, $smarty_obj) { /* @var $smarty_obj Smarty */ list($plugin_id, $tag, $tpl_path) = explode(':', $tpl_name, 3); if (empty($plugin_id) || empty($tpl_path)) { return false; } $plugins = DevblocksPlatform::getPluginRegistry(); $db = DevblocksPlatform::getDatabaseService(); if (null == ($plugin = @$plugins[$plugin_id])) { /* @var $plugin DevblocksPluginManifest */ return false; } // Check if template is overloaded in DB/cache $matches = DAO_DevblocksTemplate::getWhere(sprintf("plugin_id = %s AND path = %s %s", $db->qstr($plugin_id), $db->qstr($tpl_path), !empty($tag) ? sprintf("AND tag = %s ", $db->qstr($tag)) : "")); if (!empty($matches)) { $match = array_shift($matches); /* @var $match Model_DevblocksTemplate */ // echo time(),"==(DB)",$match->last_updated,"<BR>"; $tpl_timestamp = $match->last_updated; return true; } // If not in DB, check plugin's relative path on disk $path = APP_PATH . '/' . $plugin->dir . '/templates/' . $tpl_path; if (!file_exists($path)) { return false; } $stat = stat($path); $tpl_timestamp = $stat['mtime']; // echo time(),"==(DISK)",$stat['mtime'],"<BR>"; return true; }
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'); }