public function runResolve(framework\Request $request) { $theme = isset($request['theme_name']) ? $request['theme_name'] : framework\Settings::getThemeName(); if ($request->hasParameter('css')) { $this->getResponse()->setContentType('text/css'); if (!$request->hasParameter('theme_name')) { $basepath = THEBUGGENIE_PATH . 'public' . DS . 'css'; $asset = THEBUGGENIE_PATH . 'public' . DS . 'css' . DS . $request->getParameter('css'); } else { $basepath = THEBUGGENIE_PATH . 'themes'; $asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'css' . DS . $request->getParameter('css'); } } elseif ($request->hasParameter('js')) { $this->getResponse()->setContentType('text/javascript'); if ($request->hasParameter('theme_name')) { $basepath = THEBUGGENIE_PATH . 'themes'; $asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'js' . DS . $request->getParameter('js'); } elseif ($request->hasParameter('module_name') && framework\Context::isModuleLoaded($request['module_name'])) { $module_path = framework\Context::isInternalModule($request['module_name']) ? THEBUGGENIE_INTERNAL_MODULES_PATH : THEBUGGENIE_MODULES_PATH; $basepath = $module_path . $request['module_name'] . DS . 'public' . DS . 'js'; $asset = $module_path . $request['module_name'] . DS . 'public' . DS . 'js' . DS . $request->getParameter('js'); } else { $basepath = THEBUGGENIE_PATH . 'public' . DS . 'js'; $asset = THEBUGGENIE_PATH . 'public' . DS . 'js' . DS . $request->getParameter('js'); } } else { throw new \Exception('The expected theme Asset type is not supported.'); } $fileAsset = new AssetCollection(array(new FileAsset($asset, array(), $basepath))); $fileAsset->load(); // Do not decorate the asset with the theme's header/footer $this->getResponse()->setDecoration(framework\Response::DECORATE_NONE); return $this->renderText($fileAsset->dump()); }
public function getEmailTemplates($template, $parameters = array()) { if (!array_key_exists('module', $parameters)) { $parameters['module'] = $this; } $message_plain = framework\Action::returnComponentHTML("mailing/{$template}.text", $parameters); $html = framework\Action::returnComponentHTML("mailing/{$template}.html", $parameters); $styles = file_get_contents(THEBUGGENIE_MODULES_PATH . 'mailing' . DS . 'fixtures' . DS . framework\Settings::getThemeName() . '.css'); $message_html = <<<EOT <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <meta http-equiv=Content-Type content="text/html; charset=utf-8"> <style type="text/css"> {$styles} </style> </head> <body> {$html} </body> </html> EOT; return array($message_plain, $message_html); }
" type="application/opensearchdescription+xml" rel="search"> <?php foreach ($tbg_response->getFeeds() as $feed_url => $feed_title) { ?> <link rel="alternate" type="application/rss+xml" title="<?php echo str_replace('"', '\'', $feed_title); ?> " href="<?php echo $feed_url; ?> "> <?php } ?> <?php include THEBUGGENIE_PATH . 'themes' . DS . \thebuggenie\core\framework\Settings::getThemeName() . DS . 'theme.php'; ?> <?php list($localcss, $externalcss) = $tbg_response->getStylesheets(); ?> <?php foreach ($localcss as $css) { ?> <link rel="stylesheet" href="<?php print $css; ?> "> <?php } ?>
protected static function setupLayoutProperties($content) { $basepath = THEBUGGENIE_PATH . THEBUGGENIE_PUBLIC_FOLDER_NAME . DS; $theme = \thebuggenie\core\framework\Settings::getThemeName(); $themepath = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS; foreach (self::getModules() as $module) { $module_path = self::isInternalModule($module->getName()) ? THEBUGGENIE_INTERNAL_MODULES_PATH : THEBUGGENIE_MODULES_PATH; $module_name = $module->getName(); if (file_exists($module_path . $module_name . DS . 'css' . DS . "{$module_name}.css")) { self::getResponse()->addStylesheet(self::getRouting()->generate('asset_module_css', array('module_name' => $module_name, 'css' => "{$module_name}.css"))); } if (file_exists($themepath . 'css' . DS . "{$module_name}.css")) { self::getResponse()->addStylesheet(self::getRouting()->generate('asset_css', array('theme_name' => $theme, 'css' => "{$module_name}.css"))); } if (file_exists($basepath . 'js' . DS . "{$module_name}.js")) { self::getResponse()->addJavascript(self::getRouting()->generate('asset_js_unthemed', array('js' => "{$module_name}.js"))); } } list($localjs, $externaljs) = self::getResponse()->getJavascripts(); $webroot = self::getWebroot(); $values = compact('content', 'localjs', 'externaljs', 'webroot'); return $values; }
/** * Generate captcha picture * * @Route(name="captcha", url="/captcha/*") * @AnonymousRoute * * @param \thebuggenie\core\framework\Request $request The request object * @global array $_SESSION['activation_number'] The session captcha activation number */ public function runCaptcha(framework\Request $request) { framework\Context::loadLibrary('ui'); if (!function_exists('imagecreatetruecolor')) { return $this->return404(); } $this->getResponse()->setContentType('image/png'); $this->getResponse()->setDecoration(\thebuggenie\core\framework\Response::DECORATE_NONE); $chain = str_split($_SESSION['activation_number'], 1); $size = getimagesize(THEBUGGENIE_PATH . DS . 'themes' . DS . framework\Settings::getThemeName() . DS . 'numbers/0.png'); $captcha = imagecreatetruecolor($size[0] * sizeof($chain), $size[1]); foreach ($chain as $n => $number) { $pic = imagecreatefrompng(THEBUGGENIE_PATH . DS . 'themes' . DS . framework\Settings::getThemeName() . DS . "numbers/{$number}.png"); imagecopymerge($captcha, $pic, $size[0] * $n, 0, 0, 0, imagesx($pic), imagesy($pic), 100); imagedestroy($pic); } imagepng($captcha); imagedestroy($captcha); return true; }
/** * Reverts an issue field back to the original value * * @param \thebuggenie\core\framework\Request $request */ public function runIssueRevertField(framework\Request $request) { if ($issue_id = $request['issue_id']) { try { $issue = entities\Issue::getB2DBTable()->selectById($issue_id); } catch (\Exception $e) { $this->getResponse()->setHttpStatus(400); return $this->renderText('fail'); } } else { $this->getResponse()->setHttpStatus(400); return $this->renderText('no issue'); } $field = null; framework\Context::loadLibrary('common'); switch ($request['field']) { case 'description': $issue->revertDescription(); $issue->revertDescription_Syntax(); $field = array('id' => (int) ($issue->getDescription() != ''), 'name' => $issue->getParsedDescription(array('issue' => $issue)), 'form_value' => $issue->getDescription()); break; case 'reproduction_steps': $issue->revertReproduction_Steps(); $issue->revertReproduction_Steps_Syntax(); $field = array('id' => (int) ($issue->getReproductionSteps() != ''), 'name' => $issue->getParsedReproductionSteps(array('issue' => $issue)), 'form_value' => $issue->getReproductionSteps()); break; case 'title': $issue->revertTitle(); $field = array('id' => 1, 'name' => strip_tags($issue->getTitle())); break; case 'shortname': $issue->revertShortname(); $field = array('id' => 1, 'name' => strip_tags($issue->getShortname())); break; case 'category': $issue->revertCategory(); $field = $issue->getCategory() instanceof entities\Category ? array('id' => $issue->getCategory()->getID(), 'name' => $issue->getCategory()->getName()) : array('id' => 0); break; case 'resolution': $issue->revertResolution(); $field = $issue->getResolution() instanceof entities\Resolution ? array('id' => $issue->getResolution()->getID(), 'name' => $issue->getResolution()->getName()) : array('id' => 0); break; case 'severity': $issue->revertSeverity(); $field = $issue->getSeverity() instanceof entities\Severity ? array('id' => $issue->getSeverity()->getID(), 'name' => $issue->getSeverity()->getName()) : array('id' => 0); break; case 'reproducability': $issue->revertReproducability(); $field = $issue->getReproducability() instanceof entities\Reproducability ? array('id' => $issue->getReproducability()->getID(), 'name' => $issue->getReproducability()->getName()) : array('id' => 0); break; case 'priority': $issue->revertPriority(); $field = $issue->getPriority() instanceof entities\Priority ? array('id' => $issue->getPriority()->getID(), 'name' => $issue->getPriority()->getName()) : array('id' => 0); break; case 'percent_complete': $issue->revertPercentCompleted(); $field = $issue->getPercentCompleted(); break; case 'status': $issue->revertStatus(); $field = $issue->getStatus() instanceof entities\Status ? array('id' => $issue->getStatus()->getID(), 'name' => $issue->getStatus()->getName(), 'color' => $issue->getStatus()->getColor()) : array('id' => 0); break; case 'pain_bug_type': $issue->revertPainBugType(); $field = $issue->hasPainBugType() ? array('id' => $issue->getPainBugType(), 'name' => $issue->getPainBugTypeLabel(), 'user_pain' => $issue->getUserPain()) : array('id' => 0, 'user_pain' => $issue->getUserPain()); break; case 'pain_likelihood': $issue->revertPainLikelihood(); $field = $issue->hasPainLikelihood() ? array('id' => $issue->getPainLikelihood(), 'name' => $issue->getPainLikelihoodLabel(), 'user_pain' => $issue->getUserPain()) : array('id' => 0, 'user_pain' => $issue->getUserPain()); break; case 'pain_effect': $issue->revertPainEffect(); $field = $issue->hasPainEffect() ? array('id' => $issue->getPainEffect(), 'name' => $issue->getPainEffectLabel(), 'user_pain' => $issue->getUserPain()) : array('id' => 0, 'user_pain' => $issue->getUserPain()); break; case 'issuetype': $issue->revertIssuetype(); $field = $issue->getIssuetype() instanceof entities\Issuetype ? array('id' => $issue->getIssuetype()->getID(), 'name' => $issue->getIssuetype()->getName(), 'src' => htmlspecialchars(framework\Context::getWebroot() . 'iconsets/' . framework\Settings::getThemeName() . '/' . $issue->getIssuetype()->getIcon() . '_small.png')) : array('id' => 0); $visible_fields = $issue->getIssuetype() instanceof entities\Issuetype ? $issue->getProject()->getVisibleFieldsArray($issue->getIssuetype()->getID()) : array(); return $this->renderJSON(array('ok' => true, 'issue_id' => $issue->getID(), 'field' => $field, 'visible_fields' => $visible_fields)); break; case 'milestone': $issue->revertMilestone(); $field = $issue->getMilestone() instanceof entities\Milestone ? array('id' => $issue->getMilestone()->getID(), 'name' => $issue->getMilestone()->getName()) : array('id' => 0); break; case 'estimated_time': $issue->revertEstimatedTime(); return $this->renderJSON(array('ok' => true, 'issue_id' => $issue->getID(), 'field' => $issue->hasEstimatedTime() ? array('id' => 1, 'name' => entities\Issue::getFormattedTime($issue->getEstimatedTime())) : array('id' => 0), 'values' => $issue->getEstimatedTime(), 'percentbar' => $this->getComponentHTML('main/percentbar', array('percent' => $issue->getEstimatedPercentCompleted(), 'height' => 3)))); break; case 'spent_time': $issue->revertSpentTime(); return $this->renderJSON(array('ok' => true, 'issue_id' => $issue->getID(), 'field' => $issue->hasSpentTime() ? array('id' => 1, 'name' => entities\Issue::getFormattedTime($issue->getSpentTime())) : array('id' => 0), 'values' => $issue->getSpentTime())); break; case 'owned_by': $issue->revertOwner(); return $this->renderJSON(array('changed' => $issue->isOwnerChanged(), 'field' => $issue->isOwned() ? array('id' => $issue->getOwner()->getID(), 'name' => $issue->getOwner() instanceof entities\User ? $this->getComponentHTML('main/userdropdown', array('user' => $issue->getOwner())) : $this->getComponentHTML('main/teamdropdown', array('team' => $issue->getOwner()))) : array('id' => 0))); break; case 'assigned_to': $issue->revertAssignee(); return $this->renderJSON(array('changed' => $issue->isAssigneeChanged(), 'field' => $issue->isAssigned() ? array('id' => $issue->getAssignee()->getID(), 'name' => $issue->getAssignee() instanceof entities\User ? $this->getComponentHTML('main/userdropdown', array('user' => $issue->getAssignee())) : $this->getComponentHTML('main/teamdropdown', array('team' => $issue->getAssignee()))) : array('id' => 0))); break; case 'posted_by': $issue->revertPostedBy(); return $this->renderJSON(array('changed' => $issue->isPostedByChanged(), 'field' => array('id' => $issue->getPostedByID(), 'name' => $this->getComponentHTML('main/userdropdown', array('user' => $issue->getPostedBy()))))); break; default: if ($customdatatype = entities\CustomDatatype::getByKey($request['field'])) { $key = $customdatatype->getKey(); $revert_methodname = "revertCustomfield{$key}"; $issue->{$revert_methodname}(); if ($customdatatype->hasCustomOptions()) { $field = $issue->getCustomField($key) instanceof entities\CustomDatatypeOption ? array('value' => $issue->getCustomField($key)->getID(), 'name' => $issue->getCustomField($key)->getName()) : array('id' => 0); } else { switch ($customdatatype->getType()) { case entities\CustomDatatype::INPUT_TEXTAREA_MAIN: case entities\CustomDatatype::INPUT_TEXTAREA_SMALL: $field = $issue->getCustomField($key) != '' ? array('value' => $key, 'name' => tbg_parse_text($issue->getCustomField($key))) : array('id' => 0); break; default: $field = $issue->getCustomField($key) != '' ? array('value' => $key, 'name' => $issue->getCustomField($key)) : array('id' => 0); break; } } } break; } if ($field !== null) { return $this->renderJSON(array('ok' => true, 'issue_id' => $issue->getID(), 'field' => $field)); } else { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => framework\Context::getI18n()->__('No valid field specified (%field)', array('%field' => $request['field'])))); } }
public function runResolve(framework\Request $request) { $theme = isset($request['theme_name']) ? $request['theme_name'] : framework\Settings::getThemeName(); $module_path = framework\Context::isInternalModule($request['module_name']) ? THEBUGGENIE_INTERNAL_MODULES_PATH : THEBUGGENIE_MODULES_PATH; if ($request->hasParameter('css')) { $this->getResponse()->setContentType('text/css'); if ($request->hasParameter('module_name') && framework\Context::isModuleLoaded($request['module_name'])) { $basepath = $module_path . $request['module_name'] . DS . 'public' . DS . 'css'; $asset = $module_path . $request['module_name'] . DS . 'public' . DS . 'css' . DS . $request->getParameter('css'); } elseif (!$request->hasParameter('theme_name')) { $basepath = THEBUGGENIE_PATH . 'public' . DS . 'css'; $asset = THEBUGGENIE_PATH . 'public' . DS . 'css' . DS . $request->getParameter('css'); } else { $basepath = THEBUGGENIE_PATH . 'themes'; $asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'css' . DS . $request->getParameter('css'); } } elseif ($request->hasParameter('js')) { $this->getResponse()->setContentType('text/javascript'); if ($request->hasParameter('theme_name')) { $basepath = THEBUGGENIE_PATH . 'themes'; $asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'js' . DS . $request->getParameter('js'); } elseif ($request->hasParameter('module_name') && framework\Context::isModuleLoaded($request['module_name'])) { $basepath = $module_path . $request['module_name'] . DS . 'public' . DS . 'js'; $asset = $module_path . $request['module_name'] . DS . 'public' . DS . 'js' . DS . $request->getParameter('js'); } else { $basepath = THEBUGGENIE_PATH . 'public' . DS . 'js'; $asset = THEBUGGENIE_PATH . 'public' . DS . 'js' . DS . $request->getParameter('js'); } } elseif ($request->hasParameter('image')) { $basepath = THEBUGGENIE_PATH . 'themes'; $asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'images'; if (isset($request['module_name'])) { $asset .= DS . "modules" . DS . $request['module_name']; } if (isset($request['folder'])) { $asset .= DS . $request['folder']; } $asset .= DS . $request->getParameter('image'); if (!file_exists($asset) && isset($request['module_name']) && framework\Context::isModuleLoaded($request['module_name'])) { $basepath = $module_path . $request['module_name'] . DS . 'public' . DS . 'images'; $asset = $module_path . $request['module_name'] . DS . 'public' . DS . 'images'; if (isset($request['folder'])) { $asset .= DS . $request['folder']; } $asset .= DS . $request->getParameter('image'); } $fileinfo = finfo_open(FILEINFO_MIME_TYPE); $mimetype = finfo_file($fileinfo, $asset); finfo_close($fileinfo); $this->getResponse()->setContentType($mimetype); } else { throw new \Exception('The expected theme Asset type is not supported.'); } $last_modified = filemtime($asset); $this->getResponse()->addHeader('Cache-Control: max-age=3600, must-revalidate'); $this->getResponse()->addHeader('Last-Modified: ' . gmdate('D, d M Y H:i:s ', $last_modified) . 'GMT'); $this->getResponse()->addHeader('ETag: ' . md5($last_modified)); if (!$this->getResponse()->isModified($last_modified)) { return $this->return304(); } $fileAsset = new AssetCollection(array(new FileAsset($asset, array(), $basepath))); $fileAsset->load(); // Do not decorate the asset with the theme's header/footer $this->getResponse()->setDecoration(framework\Response::DECORATE_NONE); return $this->renderText($fileAsset->dump()); }
protected static function setupLayoutProperties($content) { $basepath = THEBUGGENIE_PATH . THEBUGGENIE_PUBLIC_FOLDER_NAME . DS; $theme = \thebuggenie\core\framework\Settings::getThemeName(); foreach (self::getModules() as $module) { if (file_exists($basepath . 'css' . DS . $theme . DS . "{$module->getName()}.css")) { self::getResponse()->addStylesheet("{$theme}/{$module->getName()}.css"); } if (file_exists($basepath . 'js' . DS . "{$module->getName()}.js")) { self::getResponse()->addJavascript($module->getName()); } } list($localjs, $externaljs) = self::getResponse()->getJavascripts(); $webroot = self::getWebroot(); $values = compact('content', 'localjs', 'externaljs', 'webroot'); return $values; }
public function componentTheme() { $this->enabled = \thebuggenie\core\framework\Settings::getThemeName() == $this->theme['key']; $this->is_default_scope = framework\Context::getScope()->isDefault(); }