本文整理汇总了PHP中Jaws_Gadget::IsGadgetInstalled方法的典型用法代码示例。如果您正苦于以下问题:PHP Jaws_Gadget::IsGadgetInstalled方法的具体用法?PHP Jaws_Gadget::IsGadgetInstalled怎么用?PHP Jaws_Gadget::IsGadgetInstalled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jaws_Gadget
的用法示例。
在下文中一共展示了Jaws_Gadget::IsGadgetInstalled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetPage
/**
* Gets a single page
*
* @access public
* @param mixed $id ID or fast_url of the page (int/string)
* @param string $language Page language
* @return mixed Array of the page information or Jaws_Error on failure
*/
function GetPage($id, $language = '')
{
$spTable = Jaws_ORM::getInstance()->table('static_pages as sp');
$spTable->select('sp.page_id:integer', 'sp.group_id:integer', 'spt.translation_id:integer', 'spt.language', 'spt.title', 'sp.fast_url', 'spt.published:boolean', 'sp.show_title:boolean', 'spt.content', 'spt.user:integer', 'spt.meta_keywords', 'spt.meta_description', 'spt.updated');
$spTable->join('static_pages_translation as spt', 'sp.page_id', 'spt.base_id');
if (empty($language)) {
$spTable->where('spt.language', array('sp.base_language', 'expr'));
} else {
$spTable->where('spt.language', $language);
}
if (is_numeric($id)) {
$spTable->and()->where('sp.page_id', $id);
} else {
$spTable->and()->where('sp.fast_url', $id);
}
$page = $spTable->fetchRow();
if (!empty($page)) {
$page['tags'] = '';
if (Jaws_Gadget::IsGadgetInstalled('Tags')) {
$model = Jaws_Gadget::getInstance('Tags')->model->loadAdmin('Tags');
$tags = $model->GetReferenceTags('StaticPage', 'page', $page['translation_id']);
$page['tags'] = implode(',', array_filter($tags));
}
}
return $page;
}
示例2: MenuBar
/**
* Displays admin menu bar according to selected action
*
* @access public
* @param string $action_selected selected action
* @return string XHTML template content
*/
function MenuBar($action_selected)
{
$actions = array('Summary', 'NewEntry', 'ListEntries', 'ManageComments', 'ManageTrackbacks', 'ManageCategories', 'AdditionalSettings');
if (!in_array($action_selected, $actions)) {
$action_selected = 'ListEntries';
}
$menubar = new Jaws_Widgets_Menubar();
$menubar->AddOption('Summary', _t('BLOG_SUMMARY'), BASE_SCRIPT . '?gadget=Blog&action=Summary', 'images/stock/new.png');
if ($this->gadget->GetPermission('AddEntries')) {
$menubar->AddOption('NewEntry', _t('BLOG_NEW_ENTRY'), BASE_SCRIPT . '?gadget=Blog&action=NewEntry', 'images/stock/new.png');
}
$menubar->AddOption('ListEntries', _t('BLOG_LIST_ENTRIES'), BASE_SCRIPT . '?gadget=Blog&action=ListEntries', 'images/stock/edit.png');
if (Jaws_Gadget::IsGadgetInstalled('Comments') && $this->gadget->GetPermission('ManageComments')) {
$menubar->AddOption('ManageComments', _t('BLOG_MANAGE_COMMENTS'), BASE_SCRIPT . '?gadget=Blog&action=ManageComments', 'images/stock/stock-comments.png');
}
if ($this->gadget->GetPermission('ManageTrackbacks')) {
$menubar->AddOption('ManageTrackbacks', _t('BLOG_MANAGE_TRACKBACKS'), BASE_SCRIPT . '?gadget=Blog&action=ManageTrackbacks', 'images/stock/stock-comments.png');
}
if ($this->gadget->GetPermission('ManageCategories')) {
$menubar->AddOption('ManageCategories', _t('BLOG_CATEGORIES'), BASE_SCRIPT . '?gadget=Blog&action=ManageCategories', 'images/stock/edit.png');
}
if ($this->gadget->GetPermission('Settings')) {
$menubar->AddOption('AdditionalSettings', _t('BLOG_SETTINGS'), BASE_SCRIPT . '?gadget=Blog&action=AdditionalSettings', 'images/stock/properties.png');
}
$menubar->Activate($action_selected);
return $menubar->Get();
}
示例3: Shout
/**
* Shouts a call to the listener object that will act immediately.
*
* @access public
* @param string $shouter Shouter class|gadget name
* @param string $event Event name
* @param mixed $params Event param(s)
* @param string $gadget If set, returns listener result of this gadget
* @param bool $broadcast Broadcast event to all listeners
* @return mixed True if successfully, otherwise returns Jaws_Error
*/
function Shout($shouter, $event, $params = array(), $gadget = '', $broadcast = true)
{
$listeners = $this->GetEventListeners($event);
if (Jaws_Error::IsError($listeners)) {
return $listeners;
}
$result = null;
foreach ($listeners as $listener) {
// check event broadcasting
if (!$broadcast && $listener['gadget'] !== $gadget) {
continue;
}
if (Jaws_Gadget::IsGadgetInstalled($listener['gadget'])) {
$objGadget = Jaws_Gadget::getInstance($listener['gadget']);
if (Jaws_Error::IsError($objGadget)) {
continue;
}
$objEvent = $objGadget->event->load($event);
if (Jaws_Error::IsError($objEvent)) {
continue;
}
$response = $objEvent->Execute($shouter, $params);
// return listener result
if ($gadget == $listener['gadget']) {
$result = $response;
}
}
}
return $result;
}
示例4: ManageComments
/**
* Displays blog comments manager
*
* @access public
* @return string XHTML template content
*/
function ManageComments()
{
$this->gadget->CheckPermission('ManageComments');
if (!Jaws_Gadget::IsGadgetInstalled('Comments')) {
Jaws_Header::Location(BASE_SCRIPT . '?gadget=Blog');
}
$cHTML = Jaws_Gadget::getInstance('Comments')->action->loadAdmin('Comments');
return $cHTML->Comments($this->gadget->name, $this->MenuBar('ManageComments'));
}
示例5: GetGadgetsList
/**
* Fetches list of gadgets, installed/not installed, core/none core, has layout/has not, ...
*
* @access public
* @param bool $core_gadget accepts true/false/null
* @param bool $installed accepts true/false/null
* @param bool $updated accepts true/false/null
* @param bool $has_html accepts true/false/null
* @return array List of gadgets
*/
function GetGadgetsList($core_gadget = null, $installed = null, $updated = null, $has_html = null)
{
//TODO: implementing cache for this method
static $gadgetsList;
if (!isset($gadgetsList)) {
$gadgetsList = array();
$gDir = JAWS_PATH . 'gadgets' . DIRECTORY_SEPARATOR;
if (!is_dir($gDir)) {
Jaws_Error::Fatal('The gadgets directory does not exists!', __FILE__, __LINE__);
}
$installed_gadgets = $GLOBALS['app']->Registry->fetch('gadgets_installed_items');
$installed_gadgets = array_filter(explode(',', $installed_gadgets));
$disabled_gadgets = $GLOBALS['app']->Registry->fetch('gadgets_disabled_items');
$gadgets = scandir($gDir);
foreach ($gadgets as $gadget) {
if ($gadget[0] == '.' || !is_dir($gDir . $gadget)) {
continue;
}
if (!$this->gadget->GetPermission(JAWS_SCRIPT == 'index' ? 'default' : 'default_admin', '', false, $gadget)) {
continue;
}
$objGadget = Jaws_Gadget::getInstance($gadget);
if (Jaws_Error::IsError($objGadget)) {
continue;
}
$gInstalled = Jaws_Gadget::IsGadgetInstalled($gadget);
if ($gInstalled) {
$gUpdated = Jaws_Gadget::IsGadgetUpdated($gadget);
} else {
$gUpdated = true;
}
$index = urlencode($objGadget->title) . $gadget;
$section = strtolower($objGadget->GetSection());
switch ($section) {
case 'general':
$order = str_pad(array_search($gadget, $installed_gadgets), 2, '0', STR_PAD_LEFT);
$index = '0' . $section . $order . $index;
break;
case 'gadgets':
$index = '2' . $section . $index;
break;
default:
$index = '1' . $section . $index;
break;
}
$gadgetsList[$index] = array('section' => $section, 'name' => $gadget, 'title' => $objGadget->title, 'core_gadget' => $objGadget->_IsCore, 'description' => $objGadget->description, 'version' => $objGadget->version, 'installed' => (bool) $gInstalled, 'updated' => (bool) $gUpdated, 'disabled' => strpos($disabled_gadgets, ",{$gadget},") !== false, 'has_html' => $objGadget->default_action ? true : false);
}
ksort($gadgetsList);
}
$resList = array();
foreach ($gadgetsList as $gadget) {
if ((is_null($core_gadget) || $gadget['core_gadget'] == $core_gadget) && (is_null($installed) || $gadget['installed'] == $installed) && (is_null($updated) || $gadget['updated'] == $updated) && (is_null($has_html) || $gadget['has_html'] == $has_html)) {
$resList[$gadget['name']] = $gadget;
}
}
return $resList;
}
示例6: Run
/**
* Does any actions required to finish the stage, such as DB queries.
*
* @access public
* @return bool|Jaws_Error Either true on success, or a Jaws_Error
* containing the reason for failure.
*/
function Run()
{
// Connect to database
require_once JAWS_PATH . 'include/Jaws/DB.php';
$objDatabase = Jaws_DB::getInstance('default', $_SESSION['upgrade']['Database']);
if (Jaws_Error::IsError($objDatabase)) {
_log(JAWS_LOG_DEBUG, "There was a problem connecting to the database, please check the details and try again");
return new Jaws_Error(_t('UPGRADE_DB_RESPONSE_CONNECT_FAILED'), 0, JAWS_ERROR_WARNING);
}
// upgrade core database schema
$old_schema = JAWS_PATH . 'upgrade/Resources/schema/0.9.0.xml';
$new_schema = JAWS_PATH . 'upgrade/Resources/schema/schema.xml';
if (!file_exists($old_schema)) {
return new Jaws_Error(_t('GLOBAL_ERROR_SQLFILE_NOT_EXISTS', '0.9.0.xml'), 0, JAWS_ERROR_ERROR);
}
if (!file_exists($new_schema)) {
return new Jaws_Error(_t('GLOBAL_ERROR_SQLFILE_NOT_EXISTS', 'schema.xml'), 0, JAWS_ERROR_ERROR);
}
_log(JAWS_LOG_DEBUG, "Upgrading core schema");
$result = Jaws_DB::getInstance()->installSchema($new_schema, '', $old_schema);
if (Jaws_Error::isError($result)) {
_log(JAWS_LOG_ERROR, $result->getMessage());
if ($result->getCode() !== MDB2_ERROR_ALREADY_EXISTS) {
return new Jaws_Error($result->getMessage(), 0, JAWS_ERROR_ERROR);
}
}
// Create application
include_once JAWS_PATH . 'include/Jaws.php';
$GLOBALS['app'] = jaws();
$GLOBALS['app']->Registry->Init();
// Upgrading core gadgets
$gadgets = array('UrlMapper', 'Settings', 'ControlPanel', 'Policy', 'Layout', 'Users', 'Comments');
foreach ($gadgets as $gadget) {
$objGadget = Jaws_Gadget::getInstance($gadget);
if (Jaws_Error::IsError($objGadget)) {
_log(JAWS_LOG_DEBUG, "There was a problem loading core gadget: " . $gadget);
return $objGadget;
}
$installer = $objGadget->installer->load();
if (Jaws_Error::IsError($installer)) {
_log(JAWS_LOG_DEBUG, "There was a problem loading installer of core gadget: {$gadget}");
return $installer;
}
if (Jaws_Gadget::IsGadgetInstalled($gadget)) {
$result = $installer->UpgradeGadget();
} else {
continue;
//$result = $installer->InstallGadget();
}
if (Jaws_Error::IsError($result)) {
_log(JAWS_LOG_DEBUG, "There was a problem installing/upgrading core gadget: {$gadget}");
return $result;
}
}
return true;
}
示例7: Prepare
/**
* The preg_replace call back function
*
* @access private
* @param string $data Matched strings from preg_replace_callback
* @return string Block content or blank text
*/
function Prepare($data)
{
$blockID = isset($data[1]) ? $data[1] : '';
if (Jaws_Gadget::IsGadgetInstalled('Blocks') && !empty($blockID)) {
$objBlocks = Jaws_Gadget::getInstance('Blocks')->action->load('Block');
$result = $objBlocks->Block($blockID);
if (!Jaws_Error::isError($result)) {
return $result;
}
}
return '';
}
示例8: Archive
/**
* Displays a list of blog entries ordered by date
*
* @access public
* @return string XHTML template content
*/
function Archive()
{
$tpl = $this->gadget->template->load('Archive.html');
$model = $this->gadget->model->load('Posts');
$archiveEntries = $model->GetEntriesAsArchive();
$auxMonth = '';
$this->SetTitle(_t('BLOG_ARCHIVE'));
$tpl->SetBlock('archive');
$tpl->SetVariable('title', _t('BLOG_ARCHIVE'));
if (!Jaws_Error::IsError($archiveEntries)) {
$date = Jaws_Date::getInstance();
foreach ($archiveEntries as $entry) {
$currentMonth = $date->Format($entry['publishtime'], 'MN');
if ($currentMonth != $auxMonth) {
if ($auxMonth != '') {
$tpl->ParseBlock('archive/month');
}
$tpl->SetBlock('archive/month');
$year = $date->Format($entry['publishtime'], 'Y');
$tpl->SetVariable('month', $currentMonth);
$tpl->SetVariable('year', $year);
$auxMonth = $currentMonth;
}
$tpl->SetBlock('archive/month/record');
$tpl->SetVariable('id', $entry['id']);
$tpl->SetVariable('date', $date->Format($entry['publishtime']));
$tpl->SetVariable('date-monthname', $currentMonth);
$tpl->SetVariable('date-month', $date->Format($entry['publishtime'], 'm'));
$tpl->SetVariable('date-day', $date->Format($entry['publishtime'], 'd'));
$tpl->SetVariable('date-year', $year);
$tpl->SetVariable('date-time', $date->Format($entry['publishtime'], 'g:ia'));
$tpl->SetVariable('title', $entry['title']);
$comments = _t('BLOG_NO_COMMENT');
if (Jaws_Gadget::IsGadgetInstalled('Comments')) {
$cModel = Jaws_Gadget::getInstance('Comments')->model->load('Comments');
$commentsCount = $cModel->GetCommentsCount('Blog', 'Post', $entry['id'], '', Comments_Info::COMMENTS_STATUS_APPROVED);
if (!empty($commentsCount)) {
$comments = _t('BLOG_HAS_N_COMMENTS', $entry['comments']);
}
}
$tpl->SetVariable('comments', $comments);
$id = !empty($entry['fast_url']) ? $entry['fast_url'] : $entry['id'];
$url = $this->gadget->urlMap('SingleView', array('id' => $id));
$tpl->SetVariable('view-link', $url);
$tpl->ParseBlock('archive/month/record');
}
$tpl->ParseBlock('archive/month');
}
$tpl->ParseBlock('archive');
return $tpl->Get('archive');
}
示例9: MenuBar
/**
* Displays admin menu bar according to selected action
*
* @access public
* @param string $action selected action
* @return string XHTML template content
*/
function MenuBar($action)
{
$actions = array('Directory', 'Comments');
if (!in_array($action, $actions)) {
$action = 'Directory';
}
$menubar = new Jaws_Widgets_Menubar();
$menubar->AddOption('Directory', _t('DIRECTORY_TITLE'), BASE_SCRIPT . '?gadget=Directory&action=Directory', 'images/stock/folder.png');
if (Jaws_Gadget::IsGadgetInstalled('Comments') && $this->gadget->GetPermission('ManageComments')) {
$menubar->AddOption('Comments', _t('DIRECTORY_FILE_COMMENTS'), BASE_SCRIPT . '?gadget=Directory&action=ManageComments', 'images/stock/stock-comments.png');
}
$menubar->Activate($action);
return $menubar->Get();
}
示例10: GetLink
/**
* Get information about a link
*
* @access public
* @param int $id The links id
* @return mixed An array contains link information and Jaws_Error on error
*/
function GetLink($id)
{
$objORM = Jaws_ORM::getInstance()->table('linkdump_links');
$objORM->select('id:integer', 'gid:integer', 'title', 'description', 'url', 'fast_url', 'createtime', 'updatetime', 'clicks:integer', 'rank:integer');
$objORM->where(is_numeric($id) ? 'id' : 'fast_url', $id);
$link = $objORM->fetchRow();
if (Jaws_Error::IsError($link)) {
return $link;
}
if (Jaws_Gadget::IsGadgetInstalled('Tags')) {
if (!empty($link)) {
$model = Jaws_Gadget::getInstance('Tags')->model->loadAdmin('Tags');
$tags = $model->GetReferenceTags('LinkDump', 'link', $id);
$link['tags'] = array_filter($tags);
}
}
return $link;
}
示例11: GetSummary
/**
* Get summary of the blog
*
* @access public
* @return array An array that has the summary of blog entries
*/
function GetSummary()
{
$model = $this->gadget->model->load('DatePosts');
$summary = $model->GetPostsDateLimitation();
// Avg. entries per week
if (isset($summary['min_date'])) {
$dfirst = strtotime($summary['min_date']);
$dlast = strtotime($summary['max_date']);
$weekfirst = date('W', $dfirst);
$yearfirst = date('Y', $dfirst);
$weeklast = date('W', $dlast);
$yearlast = date('Y', $dlast);
if ($yearlast > $yearfirst) {
// Ok ok, we assume 53 weeks per year...
$nweeks = 54 - $weekfirst + 53 * ($yearlast - 1 - $yearfirst) + $weeklast;
} else {
$nweeks = $weeklast - $weekfirst;
}
if ($nweeks != 0) {
$avg = round($summary['qty_posts'] / $nweeks);
} else {
$avg = $summary['qty_posts'];
}
$summary['AvgEntriesPerWeek'] = $avg;
} else {
$summary['min_date'] = null;
$summary['max_date'] = null;
$summary['AvgEntriesPerWeek'] = null;
}
if (Jaws_Gadget::IsGadgetInstalled('Comments')) {
$cModel = Jaws_Gadget::getInstance('Comments')->model->load('Comments');
// total comments
$summary['CommentsQty'] = $cModel->GetCommentsCount($this->gadget->name);
// recent comments
$comments = $cModel->GetComments($this->gadget->name, '', '', '', array(), 10);
if (Jaws_Error::IsError($comments)) {
return $comments;
}
foreach ($comments as $r) {
$summary['Comments'][] = array('id' => $r['id'], 'name' => $r['name'], 'insert_time' => $r['insert_time']);
}
}
return $summary;
}
示例12: GetPageTranslation
/**
* Gets the translation(by translation ID) of a page
*
* @access public
* @param int $id Translation ID
* @return mixed Array translation information or Jaws_Error on failure
*/
function GetPageTranslation($id)
{
$sptTable = Jaws_ORM::getInstance()->table('static_pages_translation');
$sptTable->select('translation_id:integer', 'base_id:integer', 'title', 'content', 'language', 'meta_keywords', 'meta_description', 'user:integer', 'published:boolean', 'updated')->where('translation_id', $id);
$row = $sptTable->fetchRow();
if (Jaws_Error::IsError($row)) {
return new Jaws_Error(_t('STATICPAGE_ERROR_TRANSLATION_NOT_EXISTS'));
}
if (isset($row['translation_id'])) {
if (!empty($row)) {
if (Jaws_Gadget::IsGadgetInstalled('Tags')) {
$model = Jaws_Gadget::getInstance('Tags')->model->loadAdmin('Tags');
$tags = $model->GetReferenceTags('StaticPage', 'page', $row['translation_id']);
$row['tags'] = implode(',', array_filter($tags));
}
}
return $row;
}
return new Jaws_Error(_t('STATICPAGE_ERROR_TRANSLATION_NOT_EXISTS'));
}
示例13: ParseText
/**
* Overrides, Parses the text
*
* @access public
* @param string $html HTML to be parsed
* @return string Parsed content
*/
function ParseText($html)
{
if (file_exists(JAWS_PATH . 'gadgets/Phoo/Model.php') && Jaws_Gadget::IsGadgetInstalled('Phoo')) {
$howMany = preg_match_all("#\\[phoo album=\"(.*?)\" picture=\"(.*?)\" title=\"(.*?)\" class=\"(.*?)\" size=\"(.*?)\" linked=\"(.*?)\"\\]#si", $html, $matches);
$new_html = $html;
$url = $GLOBALS['app']->getSiteURL();
$objPhoo = Jaws_Gadget::getInstance('Phoo')->model->load('Photos');
for ($i = 0; $i < $howMany; $i++) {
$albumid = $matches[1][$i];
$imageid = $matches[2][$i];
$title = $matches[3][$i];
$clase = $matches[4][$i];
$size = $matches[5][$i];
$linked = $matches[6][$i];
$image = $objPhoo->GetImageEntry($imageid);
if (!Jaws_Error::IsError($image) && !empty($image)) {
if (strtoupper($size) == 'THUMB') {
$img_file = JAWS_DATA . 'phoo/' . $image['thumb'];
$img_url = $GLOBALS['app']->getDataURL('phoo/' . $image['thumb']);
} elseif (strtoupper($size) == 'MEDIUM') {
$img_file = JAWS_DATA . 'phoo/' . $image['medium'];
$img_url = $GLOBALS['app']->getDataURL('phoo/' . $image['medium']);
} else {
$img_file = JAWS_DATA . 'phoo/' . $image['image'];
$img_url = $GLOBALS['app']->getDataURL('phoo/' . $image['image']);
}
$imgData = Jaws_Image::getimagesize($img_file);
if (strtoupper($linked) == 'YES') {
$img_lnk = $GLOBALS['app']->Map->GetURLFor('Phoo', 'ViewImage', array('id' => $imageid, 'albumid' => $albumid));
$new_text = '<a href="' . $img_lnk . '" ><img src="' . $img_url . '" title="' . $title . '" alt="' . $title . '" class="' . $clase . '" height="' . $imgData['height'] . '" width="' . $imgData['width'] . '"/></a>';
} else {
$new_text = '<img src="' . $img_url . '" title="' . $title . '" alt="' . $title . '" class="' . $clase . '" height="' . $imgData['height'] . '" width="' . $imgData['width'] . '" />';
}
$textToReplace = "#\\[phoo album=\"" . $albumid . "\" picture=\"" . $imageid . "\" title=\"" . $title . "\" class=\"" . $clase . "\" size=\"" . $size . "\" linked=\"" . $linked . "\"\\]#";
$new_html = preg_replace($textToReplace, $new_text, $new_html);
}
}
return $new_html;
}
return $html;
}
示例14: Run
/**
* Does any actions required to finish the stage, such as DB queries.
*
* @access public
* @return bool|Jaws_Error Either true on success, or a Jaws_Error
* containing the reason for failure.
*/
function Run()
{
// Connect to database
require_once JAWS_PATH . 'include/Jaws/DB.php';
$objDatabase = Jaws_DB::getInstance('default', $_SESSION['upgrade']['Database']);
if (Jaws_Error::IsError($objDatabase)) {
_log(JAWS_LOG_DEBUG, "There was a problem connecting to the database, please check the details and try again");
return new Jaws_Error(_t('UPGRADE_DB_RESPONSE_CONNECT_FAILED'), 0, JAWS_ERROR_WARNING);
}
// Create application
include_once JAWS_PATH . 'include/Jaws.php';
$GLOBALS['app'] = jaws();
$GLOBALS['app']->Registry->Init();
// Upgrading core gadgets
$gadgets = array('Settings', 'Layout', 'Users');
foreach ($gadgets as $gadget) {
$objGadget = Jaws_Gadget::getInstance($gadget);
if (Jaws_Error::IsError($objGadget)) {
_log(JAWS_LOG_DEBUG, "There was a problem loading core gadget: " . $gadget);
return $objGadget;
}
$installer = $objGadget->installer->load();
if (Jaws_Error::IsError($installer)) {
_log(JAWS_LOG_DEBUG, "There was a problem loading installer of core gadget: {$gadget}");
return $installer;
}
if (Jaws_Gadget::IsGadgetInstalled($gadget)) {
$result = $installer->UpgradeGadget();
} else {
continue;
//$result = $installer->InstallGadget();
}
if (Jaws_Error::IsError($result)) {
_log(JAWS_LOG_DEBUG, "There was a problem installing/upgrading core gadget: {$gadget}");
return $result;
}
}
return true;
}
示例15: MenuBar
/**
* Displays a menu bar for the control panel gadget.
*
* @access protected
* @param string $action_selected The item to display as selected.
* @return string XHTML template content for menubar
*/
function MenuBar($action_selected)
{
$actions = array('Photos', 'Groups', 'ManageComments', 'AdditionalSettings', 'Import');
if (!in_array($action_selected, $actions)) {
$action_selected = 'Photos';
}
$menubar = new Jaws_Widgets_Menubar();
$menubar->AddOption('Photos', _t('PHOO_PHOTOS'), BASE_SCRIPT . '?gadget=Phoo', STOCK_IMAGE);
if ($this->gadget->GetPermission('Groups')) {
$menubar->AddOption('Groups', _t('GLOBAL_GROUPS'), BASE_SCRIPT . '?gadget=Phoo&action=Groups', 'gadgets/Phoo/Resources/images/groups_mini.png');
}
if (Jaws_Gadget::IsGadgetInstalled('Comments') && $this->gadget->GetPermission('ManageComments')) {
$menubar->AddOption('ManageComments', _t('PHOO_COMMENTS'), BASE_SCRIPT . '?gadget=Phoo&action=ManageComments', 'images/stock/stock-comments.png');
}
if ($this->gadget->GetPermission('Settings')) {
$menubar->AddOption('AdditionalSettings', _t('PHOO_ADDITIONAL_SETTINGS'), BASE_SCRIPT . '?gadget=Phoo&action=AdditionalSettings', 'images/stock/properties.png');
}
if ($this->gadget->GetPermission('Import')) {
$menubar->AddOption('Import', _t('PHOO_IMPORT'), BASE_SCRIPT . '?gadget=Phoo&action=Import', STOCK_IMAGE);
}
$menubar->Activate($action_selected);
return $menubar->Get();
}