static function install_widget($name) { if (!MExtension::check_widget($name)) { return mapi_report_message('Not a valid widget.'); } $markdown = MExtension::markdown('widget', $name); $widget = ORM::for_table('widgets')->create(); if ($widget) { $widget->name = strval($name); $widget->title = strval($markdown['title']); $widget->version = strval($markdown['version']); if (isset($markdown['description'])) { $widget->description = $markdown['description']; } $widget->enabled = 1; if ($widget->save()) { return mapi_report_message('Widget sucessfully installed.', 'success'); } else { return mapi_report_message('There was an error installing your widget.'); } } }
static function install_template($name) { if (!MExtension::check_template($name)) { return mapi_report_message('Not a valid template.'); } $markdown = MExtension::markdown('template', $name); $template = ORM::for_table('templates')->create(); if ($template) { $template->name = strval($name); $template->title = strval($markdown['title']); $template->version = strval($markdown['version']); if (isset($markdown['description'])) { $template->description = $markdown['description']; } $template->enabled = 1; if ($template->save()) { return mapi_report_message('The template was sucessfully installed.', 'success'); } else { return mapi_report_message('There was an error installing your template.'); } } print_r($module); }
$module->text .= '<div>Status: <code>Missing</code></div>'; } elseif (1 == $module->enabled) { $module->text .= '<div>Status: <code class="green">Enabled</code></div>'; } else { $module->text .= '<div>Status: <code>Disabled</code></div>'; } if (isset($module->description)) { $module->text .= '<div><p> </p><p>' . $module->description . '</p></div>'; } } } } $forinstalls = array(); if (is_array($data['forinstall']) && sizeof($data['forinstall']) > 0) { foreach ($data['forinstall'] as $module) { $markdown = MExtension::markdown('module', $module); if ($markdown && isset($markdown['title'])) { $forinstall = new stdClass(); $forinstall->name = $module; $forinstall->title = $markdown['title']; $forinstall->text = ''; if (isset($markdown['version'])) { $forinstall->text .= '<div>Version: <code class="green">' . $markdown['version'] . '</code></div>'; } if (isset($markdown['description'])) { $forinstall->text .= '<div><p> </p><p>' . $markdown['description'] . '</p></div>'; } $forinstalls[] = $forinstall; } } }
$widget->text .= '<div>Status: <code>Missing</code></div>'; } elseif (1 == $widget->enabled) { $widget->text .= '<div>Status: <code class="green">Enabled</code></div>'; } else { $widget->text .= '<div>Status: <code>Disabled</code></div>'; } if (isset($widget->description)) { $widget->text .= '<div><p> </p><p>' . $widget->description . '</p></div>'; } } } } $forinstalls = array(); if (is_array($data['forinstall']) && sizeof($data['forinstall']) > 0) { foreach ($data['forinstall'] as $widget) { $markdown = MExtension::markdown('widget', $widget); if ($markdown && isset($markdown['title'])) { $forinstall = new stdClass(); $forinstall->name = $widget; $forinstall->title = $markdown['title']; $forinstall->text = ''; if (isset($markdown['version'])) { $forinstall->text .= '<div>Version: <code class="green">' . $markdown['version'] . '</code></div>'; } if (isset($markdown['description'])) { $forinstall->text .= '<div><p> </p><p>' . $markdown['description'] . '</p></div>'; } $forinstalls[] = $forinstall; } } }
$template->text .= '<div>Status: <code class="green">Enabled</code></div>'; } else { $template->text .= '<div>Status: <code>Disabled</code></div>'; } if (isset($template->description)) { $template->text .= '<div><p> </p><p>' . $template->description . '</p></div>'; } $template->text .= '</div>'; $template->text .= '<div style="clear: both;"></div>'; } } } $forinstalls = array(); if (is_array($data['forinstall']) && sizeof($data['forinstall']) > 0) { foreach ($data['forinstall'] as $template) { $markdown = MExtension::markdown('template', $template); if ($markdown && isset($markdown['title'])) { $forinstall = new stdClass(); $forinstall->name = $template; $forinstall->title = $markdown['title']; $forinstall->text = ''; $forinstall->text .= '<div style="float: left; margin-top: 12px; margin-bottom: 12px;"><img class="media-object" style="height: 120px; width: 180px;" src="../' . MExtension::thumbnail($forinstall->name) . '" alt="" /></div>'; $forinstall->text .= '<div style="float: left; margin-top: 12px; margin-left: 12px;">'; if (isset($markdown['version'])) { $forinstall->text .= '<div>Version: <code class="green">' . $markdown['version'] . '</code></div>'; } if (isset($markdown['description'])) { $forinstall->text .= '<div><p> </p><p>' . $markdown['description'] . '</p></div>'; } $forinstall->text .= '</div>'; $forinstall->text .= '<div style="clear: both;"></div>';