CMS  Version 3.9
scroll_view.inc
Go to the documentation of this file.
1 <?php
8 class ScrollView
9 {
10  var $scroll;
11 
12  function __construct($scroll)
13  {
14  $this->scroll = $scroll;
15  }
16 
17  function renderPart($part, $partTemplate)
18  {
19  global $script;
20 
22 
23  if ($part->content_type == "Code")
24  {
25  $part->content = $this->renderCodePart($part);
26  }
27 
28  if ($part->image_id)
29  {
30  $imageStyle = $part->format('background-image: url(/action/image/show?image_id={image_id})');
31  $part->styles = ($part->styles) ? "{$part->styles}; $imageStyle" : $imageStyle;
32  }
33 
34  if (Settings::getValue("settings", "enable_inline_editing") && Settings::checkPermission("settings", "editor_roles"))
35  {
36  $versioningControls = ComponentManager::fireEvent("RenderVersioningControls", $part);
37  //$versioningEnabled = Settings::getValue("settings", "enable_content_versioning") ? "1" : "0";
38 
39  $part->content .= $part->format("<p id='inline_editing_{scroll_part_id}' class='inline_editor_toolbar'>".
40  "<a href='#' class='edit' onclick='ScrollPartManager.editPart({scroll_id}, {scroll_part_id}); return false;'>Edit</a>".
41  "{$versioningControls}</p>");
42  }
43 
44  $out = $part->format($partTemplate);
45  $out = preg_replace("/\\[((?:include|position):.*?)\\]/i", "{\$1}", $out);
46  return $out;
47  }
48 
49  function renderCodePart($part)
50  {
51  global $config;
52  global $method;
53  global $user;
54  global $script;
55  global $styles;
56  global $breadcrumbs;
57  global $dialogs;
58  global $page;
59  global $site;
60  global $section;
61  global $menu_identifier;
62  global $identifier;
63  global $section;
64 
65  trace("Rendering part '{$part->title}' with '{$part->php_code_file}'", 3);
66 
67  if ($part->php_code_file)
68  {
69  ob_start();
70 
71  try
72  {
73  $codePath = explode(",", $part->php_code_file);
74  if (count($codePath) == 2)
75  {
76  $name = $codePath[0];
77  $php_code_file = $codePath[1];
79  if (array_key_exists($name, $components))
80  {
81  $path = $components[$name]->component_path;
83 
84  include $path."/{$php_code_file}";
85 
87  }
88  else
89  {
90  throw new FakoliException("Unknown component");
91  }
92  }
93  else
94  {
96 
97  include $config['homedir']."/{$part->php_code_file}";
98 
100  }
101  $output = trim(ob_get_contents());
102  }
103  catch(Exception $e)
104  {
105  $output = $e->__toString();
106  }
107 
108  ob_end_clean();
109  }
110 
111  return $output;
112  }
113 
114  function drawView()
115  {
116  $out = "";
117  $partTemplate = Settings::getValue("scroll", "scroll_part_template");
118  $parts = $this->scroll->Parts();
119  foreach($parts as $part)
120  {
121  $out .= $this->renderPart($part, $partTemplate)."\n";
122  }
123 
124  echo $out;
125  }
126 }?>
$section
Definition: event_form.inc:44
$page
Definition: help.inc:39
$out
Definition: page.inc:66
if(! $page) $path
Definition: page.inc:57
$components
Definition: tree.inc:41
$helpTree scroll
Definition: tree.inc:44
$name
Definition: upload.inc:54
static fireEvent($event, $parameter=null, $mustBeConsumed=false)
Fire an event to all subscribers as detailed in their manifests.
FakoliException is the base exception class for all Fakoli errors.
Definition: core.inc:53
static coreTraceLevel()
Change to the configured trace level for Fakoli core code.
Definition: core.inc:1346
static getComponents()
Retrieve an array of all the currently enabled components, indexed by component name.
Definition: core.inc:206
static applicationTraceLevel()
Change to the configured trace level for application code.
Definition: core.inc:1338
renderCodePart($part)
Definition: scroll_view.inc:49
__construct($scroll)
Definition: scroll_view.inc:12
renderPart($part, $partTemplate)
Definition: scroll_view.inc:17
static getValue($component, $name)
Retrieve the value of the specified Setting.
Definition: settings.inc:104
static checkPermission($component, $name, $account=null)
Check whether a user has a specific permission.
Definition: settings.inc:241
static selectDisplayVersion($target, $param="version")
global $user
$method
Pull out a simple reference to the request method.
Definition: core.inc:1573
$output
Definition: generate.inc:9
global $config
Definition: import.inc:4
$styles
$identifier
Definition: rss.inc:37
$parts