Пример #1
0
 function display()
 {
     $catalogtree = new Tree('productcatalog');
     $catalogtree->set_param('module', 'ProductTemplates');
     $nodes = get_categories_and_products(null);
     foreach ($nodes as $node) {
         $catalogtree->add_node($node);
     }
     $this->override_popup['template_data']['treeheader'] = $catalogtree->generate_header();
     $this->override_popup['template_data']['treeinstance'] = '{literal}' . $catalogtree->generate_nodes_array() . '{/literal}';
     parent::display();
 }
Пример #2
0
 /**
  * A Static method used to build the initial treeview when the page is first displayed
  *
  * @param String div_id - this div in which to display the tree
  * @return Tree - the tree that is built
  */
 function buildTreeView($div_id, $isAlive = true)
 {
     $tree = new Tree($div_id);
     $nodes = array();
     if ($isAlive) {
         $nodes = PackageManager::getCategories('');
     }
     foreach ($nodes as $arr_node) {
         $node = new Node($arr_node['id'], $arr_node['label']);
         $node->dynamicloadfunction = 'PackageManager.loadDataForNodeForPackage';
         $node->expanded = false;
         $node->dynamic_load = true;
         $node->set_property('href', "javascript:PackageManager.catClick('treeview');");
         $tree->add_node($node);
         $node->set_property('description', $arr_node['description']);
     }
     return $tree;
 }
Пример #3
0
 //refresh tree
 $tagstree = new Tree('tagstree');
 $tagstree->set_param('module', 'KBTags');
 if ($admin) {
     $tagstree->set_param('moduleview', 'admin');
     $nodes = get_tags_nodes(false, true, null);
     $root_node = new Node('All_Tags', $mod_strings['LBL_TAGS_ROOT_LABEL']);
     foreach ($nodes as $node) {
         $root_node->add_node($node);
     }
     $href_string = "javascript:handler:SUGAR.kb.adminClick()";
     if ($root_node) {
         $root_node->set_property("href", $href_string);
     }
     $root_node->expanded = true;
     $tagstree->add_node($root_node);
 } else {
     $tagstree->set_param('moduleview', 'modal');
     //$nodes = get_tags_nodes_cached(null);
     //$nodes=get_tags_nodes(false,null);
     $nodes = get_tags_nodes(false, false, null);
     $root_node = new Node('All_Tags', $mod_strings['LBL_TAGS_ROOT_LABEL']);
     foreach ($nodes as $node) {
         $root_node->add_node($node);
     }
     $href_string = "javascript:handler:SUGAR.kb.modalClose('tagstree')";
     if ($root_node) {
         $root_node->set_property("href", $href_string);
     }
     $root_node->expanded = true;
     $tagstree->add_node($root_node);
Пример #4
0
 /**
  * returns an array of nodes that correspond to IMAP mailboxes.
  * @param bool $forceRefresh
  * @return object TreeView object
  */
 function getMailboxNodes()
 {
     global $sugar_config;
     global $current_user;
     global $app_strings;
     $tree = new Tree("frameFolders");
     $tree->tree_style = 'include/ytree/TreeView/css/check/tree.css';
     $nodes = array();
     $ie = new InboundEmail();
     $refreshOffset = $this->cacheTimeouts['folders'];
     // 5 mins.  this will be set via user prefs
     $rootNode = new ExtNode($app_strings['LBL_EMAIL_HOME_FOLDER'], $app_strings['LBL_EMAIL_HOME_FOLDER']);
     $rootNode->dynamicloadfunction = '';
     $rootNode->expanded = true;
     $rootNode->dynamic_load = true;
     $showFolders = unserialize(base64_decode($current_user->getPreference('showFolders', 'Emails')));
     if (empty($showFolders)) {
         $showFolders = array();
     }
     // INBOX NODES
     if ($current_user->hasPersonalEmail()) {
         $personals = $ie->retrieveByGroupId($current_user->id);
         foreach ($personals as $k => $personalAccount) {
             if (in_array($personalAccount->id, $showFolders)) {
                 // check for cache value
                 $cacheRoot = sugar_cached("modules/Emails/{$personalAccount->id}");
                 $this->preflightEmailCache($cacheRoot);
                 if ($this->validCacheFileExists($personalAccount->id, 'folders', "folders.php")) {
                     $mailboxes = $this->getMailBoxesFromCacheValue($personalAccount);
                 } else {
                     $mailboxes = $personalAccount->getMailboxes();
                 }
                 $acctNode = new ExtNode('Home::' . $personalAccount->name, $personalAccount->name);
                 $acctNode->dynamicloadfunction = '';
                 $acctNode->expanded = false;
                 $acctNode->set_property('cls', 'ieFolder');
                 $acctNode->set_property('ieId', $personalAccount->id);
                 $acctNode->set_property('protocol', $personalAccount->protocol);
                 if (array_key_exists('Home::' . $personalAccount->name, $this->folderStates)) {
                     if ($this->folderStates['Home::' . $personalAccount->name] == 'open') {
                         $acctNode->expanded = true;
                     }
                 }
                 $acctNode->dynamic_load = true;
                 $nodePath = $acctNode->_properties['id'];
                 foreach ($mailboxes as $k => $mbox) {
                     $acctNode->add_node($this->buildTreeNode($k, $k, $mbox, $personalAccount->id, $nodePath, false, $personalAccount));
                 }
                 $rootNode->add_node($acctNode);
             }
         }
     }
     // GROUP INBOX NODES
     $beans = $ie->retrieveAllByGroupId($current_user->id, false);
     foreach ($beans as $k => $groupAccount) {
         if (in_array($groupAccount->id, $showFolders)) {
             // check for cache value
             $cacheRoot = sugar_cached("modules/Emails/{$groupAccount->id}");
             $this->preflightEmailCache($cacheRoot);
             //$groupAccount->connectMailserver();
             if ($this->validCacheFileExists($groupAccount->id, 'folders', "folders.php")) {
                 $mailboxes = $this->getMailBoxesFromCacheValue($groupAccount);
             } else {
                 $mailboxes = $groupAccount->getMailBoxesForGroupAccount();
             }
             $acctNode = new ExtNode($groupAccount->name, "group.{$groupAccount->name}");
             $acctNode->dynamicloadfunction = '';
             $acctNode->expanded = false;
             $acctNode->set_property('isGroup', 'true');
             $acctNode->set_property('ieId', $groupAccount->id);
             $acctNode->set_property('protocol', $groupAccount->protocol);
             if (array_key_exists('Home::' . $groupAccount->name, $this->folderStates)) {
                 if ($this->folderStates['Home::' . $groupAccount->name] == 'open') {
                     $acctNode->expanded = true;
                 }
             }
             $acctNode->dynamic_load = true;
             $nodePath = $rootNode->_properties['id'] . "::" . $acctNode->_properties['id'];
             foreach ($mailboxes as $k => $mbox) {
                 $acctNode->add_node($this->buildTreeNode($k, $k, $mbox, $groupAccount->id, $nodePath, true, $groupAccount));
             }
             $rootNode->add_node($acctNode);
         }
     }
     // SugarFolder nodes
     /* SugarFolders are built at onload when the UI renders */
     $tree->add_node($rootNode);
     return $tree;
 }
Пример #5
0
 /**
  *
  */
 function process_page()
 {
     global $theme;
     global $mod_strings;
     global $app_strings;
     global $currentModule;
     global $sugar_version, $sugar_config;
     global $app_list_strings;
     global $sugar_config;
     $b_from_documents = false;
     if (isset($_REQUEST['caller']) && $_REQUEST['caller'] == 'Documents') {
         $b_from_documents = true;
     }
     //initalize template
     $form = new XTemplate('modules/Documents/Popup_picker.html');
     $form->assign('MOD', $mod_strings);
     $form->assign('APP', $app_strings);
     $form->assign('THEME', $theme);
     $form->assign('MODULE_NAME', $currentModule);
     //tree header.
     $doctree = new Tree('doctree');
     $doctree->set_param('module', 'Documents');
     if ($b_from_documents) {
         $doctree->set_param('caller', 'Documents');
         $href_string = "javascript:populate_parent_search('doctree')";
     } else {
         $href_string = "javascript:populate_search('doctree')";
     }
     $nodes = get_category_nodes($href_string);
     foreach ($nodes as $node) {
         $doctree->add_node($node);
     }
     $form->assign("TREEHEADER", $doctree->generate_header());
     $form->assign("TREEINSTANCE", $doctree->generate_nodes_array());
     $site_data = "<script> var site_url= {\"site_url\":\"" . getJavascriptSiteURL() . "\"};</script>\n";
     $form->assign("SITEURL", $site_data);
     $form->parse('main.SearchHeader.TreeView');
     $treehtml = $form->text('main.SearchHeader.TreeView');
     $form->reset('main.SearchHeader.TreeView');
     //end tree
     if (isset($_REQUEST['caller']) && $_REQUEST['caller'] == 'Documents') {
         ///process treeview and return.
         return insert_popup_header($theme) . $treehtml . insert_popup_footer();
     }
     ////////////////////////process full search form and list view.//////////////////////////////
     $output_html = '';
     $where = '';
     $where = $this->_get_where_clause();
     $name = empty($_REQUEST['name']) ? '' : $_REQUEST['name'];
     $document_name = empty($_REQUEST['document_name']) ? '' : $_REQUEST['document_name'];
     $category_id = empty($_REQUEST['category_id']) ? '' : $_REQUEST['category_id'];
     $subcategory_id = empty($_REQUEST['subcategory_id']) ? '' : $_REQUEST['subcategory_id'];
     $template_type = empty($_REQUEST['template_type']) ? '' : $_REQUEST['template_type'];
     $is_template = empty($_REQUEST['is_template']) ? '' : $_REQUEST['is_template'];
     $request_data = empty($_REQUEST['request_data']) ? '' : $_REQUEST['request_data'];
     $hide_clear_button = empty($_REQUEST['hide_clear_button']) ? false : true;
     $button = "<form action='index.php' method='post' name='form' id='form'>\n";
     if (!$hide_clear_button) {
         $button .= "<input type='button' name='button' class='button' onclick=\"send_back('','');\" title='" . $app_strings['LBL_CLEAR_BUTTON_TITLE'] . "'  value='  " . $app_strings['LBL_CLEAR_BUTTON_LABEL'] . "  ' />\n";
     }
     $button .= "<input type='submit' name='button' class='button' onclick=\"window.close();\" title='" . $app_strings['LBL_CANCEL_BUTTON_TITLE'] . "' accesskey='" . $app_strings['LBL_CANCEL_BUTTON_KEY'] . "' value='  " . $app_strings['LBL_CANCEL_BUTTON_LABEL'] . "  ' />\n";
     $button .= "</form>\n";
     $form->assign('NAME', $name);
     $form->assign('DOCUMENT_NAME', $document_name);
     $form->assign('request_data', $request_data);
     $form->assign("CATEGORY_OPTIONS", get_select_options_with_id($app_list_strings['document_category_dom'], $category_id));
     $form->assign("SUB_CATEGORY_OPTIONS", get_select_options_with_id($app_list_strings['document_subcategory_dom'], $subcategory_id));
     $form->assign("IS_TEMPLATE_OPTIONS", get_select_options_with_id($app_list_strings['checkbox_dom'], $is_template));
     $form->assign("TEMPLATE_TYPE_OPTIONS", get_select_options_with_id($app_list_strings['document_template_type_dom'], $template_type));
     ob_start();
     insert_popup_header($theme);
     $output_html .= ob_get_contents();
     ob_end_clean();
     $output_html .= get_form_header($mod_strings['LBL_SEARCH_FORM_TITLE'], '', false);
     $form->parse('main.SearchHeader');
     $output_html .= $form->text('main.SearchHeader');
     // Reset the sections that are already in the page so that they do not print again later.
     $form->reset('main.SearchHeader');
     //add tree view to output_html.
     $output_html .= $treehtml;
     // create the listview
     $seed_bean = new Document();
     $ListView = new ListView();
     $ListView->show_select_menu = false;
     $ListView->show_delete_button = false;
     $ListView->show_export_button = false;
     $ListView->process_for_popups = true;
     $ListView->setXTemplate($form);
     $ListView->setHeaderTitle($mod_strings['LBL_LIST_FORM_TITLE']);
     $ListView->setHeaderText($button);
     $ListView->setQuery($where, '', 'document_name', 'DOCUMENT');
     $ListView->setModStrings($mod_strings);
     ob_start();
     $ListView->processListView($seed_bean, 'main', 'DOCUMENT');
     $output_html .= ob_get_contents();
     ob_end_clean();
     $output_html .= insert_popup_footer();
     return $output_html;
 }
Пример #6
0
function return_advanced_tab($focus, $json, $json_config)
{
    global $theme, $image_path, $app_list_strings, $mod_strings, $app_strings;
    $ss_adv = new Sugar_Smarty();
    $ss_adv->assign("MOD", $mod_strings);
    $ss_adv->assign("APP", $app_strings);
    //assign back values from last search, if it exists.
    //do not set any values if value has been set
    if (isset($_POST['clear_loaded'])) {
        $_POST['searchText'] = '';
        foreach ($_POST as $_key => $_val) {
            $ss_adv->assign($_key, '');
        }
    } else {
        foreach ($_POST as $_key => $_val) {
            $ss_adv->assign($_key, $_val);
        }
    }
    $popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'FTSFormAdvanced', 'field_to_name_array' => array('id' => 'kbdoc_approver_id', 'name' => 'kbdoc_approver_name'));
    $ss_adv->assign('encoded_approver_popup_request_data', $json->encode($popup_request_data));
    $popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'FTSFormAdvanced', 'field_to_name_array' => array('id' => 'kbarticle_author_id', 'name' => 'kbarticle_author_name'));
    $ss_adv->assign('encoded_author_popup_request_data', $json->encode($popup_request_data));
    $popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'FTSFormAdvanced', 'field_to_name_array' => array('id' => 'tag_id', 'tag_name' => 'tag_name'));
    $ss_adv->assign('encoded_tags_popup_request_data', $json->encode($popup_request_data));
    $popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'FTSFormAdvanced', 'field_to_name_array' => array('id' => 'team_id', 'name' => 'team_name'));
    $json = getJSONobj();
    $ss_adv->assign('encoded_team_popup_request_data', $json->encode($popup_request_data));
    $ss_adv->assign("PRINT_URL", "index.php?" . $GLOBALS['request_string']);
    $ss_adv->assign("ID", $focus->id);
    $ss_adv->assign("DOCUMENT_NAME", $focus->kbdocument_name);
    $ss_adv->assign("DESCRIPTION", $focus->description);
    $ss_adv->assign("ACTIVE_DATE", $focus->active_date);
    $ss_adv->assign("EXP_DATE", $focus->exp_date);
    $status_option = "<option value='' selected>" . $app_strings['LBL_NONE'] . "</option> ";
    if (isset($_POST['status_id'])) {
        $status_option .= get_select_options_with_id($app_list_strings['kbdocument_status_dom'], $_POST['status_id']);
        $ss_adv->assign("STATUS_OPTIONS", $status_option);
    } else {
        $status_option .= get_select_options_with_id($app_list_strings['kbdocument_status_dom'], '');
        $ss_adv->assign("STATUS_OPTIONS", $status_option);
    }
    if (isset($_POST['saved_search_select']) && !empty($_POST['saved_search_select'])) {
        $ss_adv->assign("SAVED_SEARCH_OPTIONS", getSavedSearchOptions($focus, $_POST['saved_search_select']));
        $savedSearchSelects = $json->encode(array($GLOBALS['app_strings']['LBL_SAVED_SEARCH_SHORTCUT'] . '<br>' . getSavedSearchOptions($focus, $_POST['saved_search_select'], true)));
    } else {
        $ss_adv->assign("SAVED_SEARCH_OPTIONS", getSavedSearchOptions($focus));
        $savedSearchSelects = $json->encode(array($GLOBALS['app_strings']['LBL_SAVED_SEARCH_SHORTCUT'] . '<br>' . getSavedSearchOptions($focus, '', true)));
    }
    $str = "<script>\n    YAHOO.util.Event.addListener(window, 'load', SUGAR.util.fillShortcuts, {$savedSearchSelects});\n    </script>";
    echo $str;
    if (isset($_POST['canned_search'])) {
        $ss_adv->assign("CANNED_SEARCH_OPTIONS", get_select_options_with_id($app_list_strings['kbdocument_canned_search'], $_POST['canned_search']));
    } else {
        $ss_adv->assign("CANNED_SEARCH_OPTIONS", get_select_options_with_id($app_list_strings['kbdocument_canned_search'], ''));
    }
    $a1_style = '';
    $x1_style = '';
    $a2_style = 'none';
    $x2_style = 'none';
    //set the expiration date filter if it exists.  Also set the style properties
    //that will determine whether to show or hide the supporting text boxes
    if (isset($_POST['active_date_filter'])) {
        $ss_adv->assign("ACTIVE_DATE_FILTER_OPTIONS", get_select_options_with_id($app_list_strings['kbdocument_date_filter_options'], $_POST['active_date_filter']));
        if ($_POST['active_date_filter'] == 'on' || $_POST['active_date_filter'] == 'before' || $_POST['active_date_filter'] == 'after') {
            $a1_style = '';
        } else {
            $a1_style = 'none';
        }
        if ($_POST['active_date_filter'] == 'between_dates') {
            $a2_style = '';
        }
    } else {
        $ss_adv->assign("ACTIVE_DATE_FILTER_OPTIONS", get_select_options_with_id($app_list_strings['kbdocument_date_filter_options'], ''));
    }
    //set the expiration date filter if it exists.  Also set the style properties
    //that will determine whether to show or hide the supporting text boxes
    if (isset($_POST['exp_date_filter'])) {
        $ss_adv->assign("EXP_DATE_FILTER_OPTIONS", get_select_options_with_id($app_list_strings['kbdocument_date_filter_options'], $_POST['exp_date_filter']));
        if ($_POST['exp_date_filter'] == 'on' || $_POST['exp_date_filter'] == 'before' || $_POST['exp_date_filter'] == 'after') {
            $x1_style = '';
        } else {
            $x1_style = 'none';
        }
        if ($_POST['exp_date_filter'] == 'between_dates') {
            $x2_style = '';
        }
    } else {
        $ss_adv->assign("EXP_DATE_FILTER_OPTIONS", get_select_options_with_id($app_list_strings['kbdocument_date_filter_options'], ''));
    }
    //set the style sheet properties for date filters
    $ss_adv->assign("A_DATE1_STYLE", $a1_style);
    $ss_adv->assign("X_DATE1_STYLE", $x1_style);
    $ss_adv->assign("A_DATE2_STYLE", $a2_style);
    $ss_adv->assign("X_DATE2_STYLE", $x2_style);
    $attach_name_style = 'none';
    $attach_mime_style = 'none';
    if (isset($_POST['attachments'])) {
        $ss_adv->assign("ATTACHMENT_SELECT_OPTIONS", get_select_options_with_id($app_list_strings['kbdocument_attachment_option_dom'], $_POST['attachments']));
        if ($_POST['attachments'] == 'mime') {
            $attach_mime_style = ' ';
        } else {
            if ($_POST['attachments'] == 'name') {
                $attach_name_style = ' ';
            }
        }
    } else {
        $ss_adv->assign("ATTACHMENT_SELECT_OPTIONS", get_select_options_with_id($app_list_strings['kbdocument_attachment_option_dom'], ''));
    }
    $ss_adv->assign("ATTACHMENT_NAME_STYLE", $attach_name_style);
    $ss_adv->assign("ATTACHMENT_MIME_STYLE", $attach_mime_style);
    if (!empty($focus->kbdoc_approver_id)) {
        $user = BeanFactory::getBean('Users', $focus->kbdoc_approver_id);
        $ss_adv->assign("KBDOC_APPROVER_NAME", $user->name);
        $ss_adv->assign("KBDOC_APPROVER_ID", $focus->kbdoc_approver_id);
    }
    global $timedate;
    $ss_adv->assign("CALENDAR_DATEFORMAT", $timedate->get_cal_date_format());
    $ss_adv->assign("USER_DATE_FORMAT", $timedate->get_user_date_format());
    $ss_adv->assign('JSON_CONFIG_JAVASCRIPT', $json_config->get_static_json_server());
    if (isset($_POST['frequency'])) {
        $ss_adv->assign("FRQ_VIEW_OPTIONS", get_select_options_with_id($app_list_strings['kbdocument_viewing_frequency_dom'], $_POST['frequency']));
    } else {
        $ss_adv->assign("FRQ_VIEW_OPTIONS", get_select_options_with_id($app_list_strings['kbdocument_viewing_frequency_dom'], ''));
    }
    if (isset($_POST['is_external_article'])) {
        if ($_POST['is_external_article']) {
            $ss_adv->assign('is_external_id', '1');
            $ss_adv->assign('is_external_checked', 'checked');
        } else {
            $ss_adv->assign('is_external_id', '0');
            $ss_adv->assign('is_external_checked', '');
        }
    }
    //create tree for tag selection modal
    $tag = BeanFactory::getBean('KBTags');
    $ss_adv->assign("TAG_NAME", $tag->tag_name);
    //tree header.
    $tagstree = new Tree('tagstree');
    $tagstree->set_param('module', 'KBTags');
    $tagstree->set_param('moduleview', 'modal');
    $nodes = get_tags_nodes(false, false, null);
    $root_node = new Node('All_Tags', $mod_strings['LBL_TAGS_ROOT_LABEL']);
    foreach ($nodes as $node) {
        $root_node->add_node($node);
    }
    $href_string = "javascript:handler:modalClose('tagstree')";
    if ($root_node) {
        $root_node->set_property("href", $href_string);
    }
    $root_node->expanded = true;
    $tagstree->add_node($root_node);
    $ss_adv->assign("TREEINSTANCE", $tagstree->generate_nodes_array());
    return $ss_adv->fetch("modules/KBDocuments/tpls/advancedTab.tpl");
}
Пример #7
0
require_once 'include/JSON.php';
require_once 'include/upload_file.php';
require_once 'vendor/ytree/Tree.php';
require_once 'vendor/ytree/Node.php';
require_once 'modules/KBTags/TreeData.php';
$json = getJSONobj();
$search_tag_name = $json->decode(html_entity_decode($_REQUEST['searchTagName']));
if (!empty($search_tag_name)) {
    //create campaign log
    $query = "select id from kbtags where deleted = '0' and tag_name={$search_tag_name} order by tag_name";
    $result = $GLOBALS['db']->query($query);
    $searched_tagIds = $GLOBALS['db']->fetchByAssoc($result);
    //next search the parents (root node) of each tag found
    //combine parent child/ren and expand tree
    $tagstree = new Tree('tagstree');
    $tagstree->set_param('module', 'KBTags');
    $tagstree->set_param('moduleview', 'SearchTags');
    $nodes = get_search_tags_nodes(true, $searched_tagIds);
    foreach ($nodes as $node) {
        $tagstree->add_node($node);
    }
}
$response = $tagstree->generate_nodes_array();
if (!empty($response)) {
    echo $response;
    //$json = getJSONobj();
    //print $json->encode($response);
    //return the parameters
}
sugar_cleanup();
exit;
    $tagstreeModal = new Tree('tagstreeMoveDocsModal');
    $tagstreeModal->set_param('module', 'KBTags');
    $tagstreeModal->set_param('moduleview', 'modalMoveDocs');
    $nodes = get_tags_modal_nodes(null, false);
    foreach ($nodes as $node) {
        $tagstreeModal->add_node($node);
    }
    $response = $tagstreeModal->generate_nodes_array();
}
if ($tagsMode == 'Apply Tags') {
    $tagstreeApply = new Tree('tagstreeApplyTags');
    $tagstreeApply->set_param('module', 'KBTags');
    $tagstreeApply->set_param('moduleview', 'applyTags');
    $nodes = get_tags_modal_nodes(null, true);
    foreach ($nodes as $node) {
        $tagstreeApply->add_node($node);
    }
    $response = $tagstreeApply->generate_nodes_array();
}
//ADDING FOR SEARCH
if ($tagsMode == 'Search Tags') {
    global $mod_strings;
    if (!empty($search_tag_name)) {
        $search_tag_name = $GLOBALS['db']->quote($search_tag_name[0]);
        $query = "select id,tag_name from kbtags where tag_name='{$search_tag_name}' and deleted = 0";
        $result = $GLOBALS['db']->query($query);
        //$searched_tagIds  =  $GLOBALS['db']->fetchByAssoc($result);
        $searched_and_related_Ids = array();
        $searched_ids = array();
        //for each search tag id find all the way to the root and save the nodes enroute
        //in the sequence.
Пример #9
0
    /**
     * @see SugarView::display()
     */
    public function display()
    {
        global $mod_strings;
        $ss = new Sugar_Smarty();
        $ss->assign("MOD", $GLOBALS['mod_strings']);
        $ss->assign("INSTRUCTION", "<h1>{$mod_strings['LNK_BROWSER']}</h1>");
        //tree header.
        $doctree = new Tree('doctree');
        $doctree->tree_style = 'include/ytree/TreeView/css/default/tree.css';
        $doctree->set_param('module', 'xeBayCategories');
        $nodes = get_node_data(array('TREE' => array('depth' => 0)), true);
        // $nodes = get_category_nodes($href_string);
        // $nodes = $this->get_test_nodes($href_string);
        foreach ($nodes as $node) {
            $doctree->add_node($node);
        }
        $ss->assign("TREEHEADER", $doctree->generate_header());
        $ss->assign("TREEINSTANCE", $doctree->generate_nodes_array());
        $site_data = "<script> var site_url= {\"site_url\":\"" . getJavascriptSiteURL() . "\"};</script>\n";
        $ss->assign("SITEURL", $site_data);
        $javascript = <<<EOQ
EOQ;
        $ss->assign("JAVASCRIPT", $javascript);
        echo $ss->fetch("modules/xeBayCategories/tpls/browser.tpl");
    }
 function display()
 {
     global $app_strings, $current_language, $mod_strings;
     require_once 'cache/dashlets/dashlets.php';
     $tree = new Tree('Dashlets');
     // key => number of dashlets in cat
     $theCats = array('Module Views' => 0, 'Portal' => 0, 'Charts' => 0, 'Tools' => 0, 'Miscellaneous' => 0);
     $categories = array();
     foreach ($theCats as $cat => $num) {
         $categories[$cat] = new Node($cat, $mod_strings['dashlet_categories_dom'][$cat], true);
     }
     $dashletStrings = array();
     asort($dashletsFiles);
     foreach ($dashletsFiles as $className => $files) {
         if (!empty($files['meta']) && is_file($files['meta'])) {
             require_once $files['meta'];
             // get meta file
             $directory = substr($files['meta'], 0, strrpos($files['meta'], '/') + 1);
             if (is_file($directory . $files['class'] . '.' . $current_language . '.lang.php')) {
                 require_once $directory . $files['class'] . '.' . $current_language . '.lang.php';
             } elseif (is_file($directory . $files['class'] . '.en_us.lang.php')) {
                 require_once $directory . $files['class'] . '.en_us.lang.php';
             }
             // try to translate the string
             if (empty($dashletStrings[$files['class']][$dashletMeta[$files['class']]['title']])) {
                 $title = $dashletMeta[$files['class']]['title'];
             } else {
                 $title = $dashletStrings[$files['class']][$dashletMeta[$files['class']]['title']];
             }
             // try to translate the string
             if (empty($dashletStrings[$files['class']][$dashletMeta[$files['class']]['description']])) {
                 $description = $dashletMeta[$files['class']]['description'];
             } else {
                 $description = $dashletStrings[$files['class']][$dashletMeta[$files['class']]['description']];
             }
             if (empty($dashletMeta[$files['class']]['icon'])) {
                 // no icon defined in meta data
                 if (empty($files['icon'])) {
                     $icon = '';
                     // no icon found
                 } else {
                     // use one found in directory
                     $icon = '<img border="0" src="' . $files['icon'] . '">';
                 }
             } else {
                 // use one defined in meta data
                 $icon = '<img border="0" src="' . $dashletMeta[$files['class']]['icon'] . '">';
             }
             $node = new Node($title, '<table cellpadding="0" border="0"><tr onclick="return SUGAR.sugarHome.addDashlet(\'' . $className . '\');" onmouseover="return overlib(\'' . $description . '\', FGCLASS, \'olFgClass\', CGCLASS, \'olCgClass\', BGCLASS, \'olBgClass\', TEXTFONTCLASS, \'olFontClass\', CAPTIONFONTCLASS, \'olCapFontClass\', CLOSEFONTCLASS, \'olCloseFontClass\' );" onmouseout="return nd();">
                             <td valign="top">' . $icon . '</td><td>' . $title . '</td></tr></table>');
             if (isset($categories[$dashletMeta[$files['class']]['category']])) {
                 // is it categorized?
                 $theCats[$dashletMeta[$files['class']]['category']]++;
                 $categories[$dashletMeta[$files['class']]['category']]->add_node($node);
             } else {
                 // default to misc cat
                 $theCats['Miscellaneous']++;
                 $categories['Miscellaneous']->add_node($node);
             }
         }
     }
     foreach ($theCats as $cat => $num) {
         if ($num != 0) {
             // only add cat if there are dashlets in this category
             $tree->add_node($categories[$cat]);
         }
     }
     return $tree->generate_nodes_array(false);
 }
Пример #11
0
    function process_page()
    {
        global $mod_strings, $app_strings, $currentModule, $seed_object, $sugar_version, $sugar_config;
        $focus = BeanFactory::getBean('ProductCategories');
        if (!isset($_REQUEST['html'])) {
            $xtpl = new XTemplate('modules/ProductCategories/Popup_picker.html');
            $GLOBALS['log']->debug("using file modules/ProductCategories/Popup_picker1.html");
        } else {
            $_REQUEST['html'] = preg_replace("/[^a-zA-Z0-9_]/", "", $_REQUEST['html']);
            $GLOBALS['log']->debug("_REQUEST['html'] is " . $_REQUEST['html']);
            $xtpl = new XTemplate('modules/ProductCategories/' . $_REQUEST['html'] . '.html');
            $GLOBALS['log']->debug("using file modules/ProductCategories/" . $_REQUEST['html'] . '.html');
        }
        insert_popup_header();
        //tree header.
        $prodcattree = new Tree('productcategories');
        $prodcattree->set_param('module', 'ProductCategories');
        $parents = array();
        if (!empty($_REQUEST['parent_category_id'])) {
            $parents = $this->find_parents($_REQUEST['parent_category_id']);
        }
        $nodes = get_product_categories(null, $parents);
        foreach ($nodes as $node) {
            $prodcattree->add_node($node);
        }
        $xtpl->assign("TREEHEADER", $prodcattree->generate_header());
        $xtpl->assign("TREEINSTANCE", $prodcattree->generate_nodes_array());
        $xtpl->assign("MODULE_NAME", $currentModule);
        global $sugar_config;
        $site_data = "<script> var site_url= {\"site_url\":\"" . getJavascriptSiteURL() . "\"};</script>\n";
        $xtpl->assign("SITEURL", $site_data);
        if (!empty($_REQUEST['form']) && $_REQUEST['form'] == 'EditView') {
            $the_javascript = "<script type='text/javascript' language='JavaScript'>\n";
            $the_javascript .= "function set_return(treeid) { \n";
            $the_javascript .= "    node=YAHOO.namespace(treeid).selectednode;";
            $the_javascript .= "    window.opener.document.EditView.parent_id.value = node.data.id;\n";
            $the_javascript .= "    window.opener.document.EditView.parent_name.value = node.label;\n";
            $the_javascript .= "     window.close();\n";
            $the_javascript .= "}\n";
            $the_javascript .= "</script>\n";
            $clear_button = "<input title='" . $app_strings['LBL_CLEAR_BUTTON_TITLE'] . "' class='button' LANGUAGE=javascript onclick=\"window.opener.document.EditView.parent_id.value = '';window.opener.document.EditView.parent_name.value = ''; window.close()\" type='submit' name='button' value='  " . $app_strings['LBL_CLEAR_BUTTON_LABEL'] . "  '>\n";
            $cancel_button = "<input title='" . $app_strings['LBL_CANCEL_BUTTON_TITLE'] . "' accessKey='" . $app_strings['LBL_CANCEL_BUTTON_KEY'] . "' class='button' LANGUAGE=javascript onclick=\"window.close()\" type='submit' name='button' value='  " . $app_strings['LBL_CANCEL_BUTTON_LABEL'] . "  '>\n";
        }
        if (empty($_REQUEST['form']) || $_REQUEST['form'] == 'EditView' && $_REQUEST['tree'] == 'ProdCat') {
            $seed_object->show_products = FALSE;
            $the_javascript = <<<END
            <script type='text/javascript' language='JavaScript'>
                var field_id = null;
                var field_name = null;

                function set_return(treeid) {

                    if(typeof treeid != 'undefined') {
                        node=YAHOO.namespace(treeid).selectednode;
                    } else {
                        node = {'data': {'id': ''}, 'label': ''};
                    }

                    if (typeof window.opener.document.forms.search_form != 'undefined' || window.opener.document.forms.popup_query_form != 'undefined') { // Search
                        var form = (typeof window.opener.document.forms.search_form != 'undefined') ? window.opener.document.forms.search_form : window.opener.document.forms.popup_query_form;
                        var searchType = (typeof form.searchFormTab != 'undefined' && form.searchFormTab.value == 'basic_search') ? 'basic' : 'advanced';

                        field_id = form['category_id_'   + searchType];
                        field_name = form['category_name_'   + searchType];
                    } else if(typeof window.opener.document.ReportsWizardForm != 'undefined') { // reports
                        field_id = window.opener.document.ReportsWizardForm['ProductCategories:name:id:1'];
                        field_name = window.opener.document.ReportsWizardForm['ProductCategories:name:name:1'];
                    } else if(typeof window.opener.document.EditView != 'undefined') {
                        field_id = window.opener.document.EditView.category_id;
                        field_name = window.opener.document.EditView.category_name;
                    }

                    if(field_id != null && field_name != null) {
                        field_id.value = node.data.id;
                        field_name.value = node.label;
                    }

                    window.close();
                }
            </script>
END;
            $clear_button = "<input title='" . $app_strings['LBL_CLEAR_BUTTON_TITLE'] . "' class='button' LANGUAGE=javascript onclick=\"set_return()\" type='submit' name='button' value='  " . $app_strings['LBL_CLEAR_BUTTON_LABEL'] . "  '>\n";
            $cancel_button = "<input title='" . $app_strings['LBL_CANCEL_BUTTON_TITLE'] . "' class='button' LANGUAGE=javascript onclick=\"window.close()\" type='submit' name='button' value='  " . $app_strings['LBL_CANCEL_BUTTON_LABEL'] . "  '>\n";
        }
        $xtpl->assign("SET_RETURN_JS", $the_javascript);
        $xtpl->assign("CLEAR_BUTTON", $clear_button);
        $xtpl->assign("CANCEL_BUTTON", $cancel_button);
        $xtpl->parse('main');
        $xtpl->out('main');
    }