'error', 'type' => 'unknown', 'msg' => $msg)); /** * invoked from navtadmin.js for configuration changes * @since .96 */ if( isset( $_POST['navtajx'] ) ) { // get the action to be taken and initialize the class $action = $_POST['navtajx']['action']; NAVTAJX::init(); // all group related changes if( $action == 'add_group' ) { $rsp = NAVTAJX::add_new_group( $_POST['group'] ); } elseif( $action == 'remove_group' ) { $rsp = NAVTAJX::remove_group( $_POST['group'] ); } elseif( $action == 'ask_remove_group' ) { $rsp = NAVTAJX::ask_remove_group( $_POST['group'] ); } elseif( $action == 'reorder_groups') { $rsp = NAVTAJX::reorder_groups( $_POST['order'] ); } elseif( $action == 'get_group_options') { $rsp = NAVTAJX::get_group_options( $_POST['group'] ); } elseif( $action == 'toggle_group_option') { $rsp = NAVTAJX::toggle_group_option( $_POST['group'], $_POST['option'] ); } elseif( $action == 'set_group_option') { $rsp = NAVTAJX::set_group_option( $_POST['group'], $_POST['option'], $_POST['setting'], $_POST['type'] ); } elseif( $action == 'save_group_options') { $rsp = NAVTAJX::save_group_options( $_POST['group'], $_POST['group_options'], $_POST['display'], $_POST['page_list'], $_POST['post_list'], $_POST['savetype'], $_POST['activetab'] ); } elseif( $action == 'get_options_help' ) { $rsp = NAVTAJX::help('group_options', $_POST['activetab']); } elseif( $action == 'navt_help') { $rsp = NAVTAJX::help( $_POST['subject'], $_POST['ltIe7']); } // all item related changes elseif( $action == 'add_group_item' ) { $rsp = NAVTAJX::add_group_item( $_POST['id'], $_POST['group'] ); } elseif( $action == 'remove_group_item' ) { $rsp = NAVTAJX::remove_group_item( $_POST['id'], $_POST['group'] ); } elseif( $action == 'get_item_options') { $rsp = NAVTAJX::get_item_options( $_POST['id'] ); } elseif( $action == 'set_item_level') { $rsp = NAVTAJX::set_item_level( $_POST['id'], $_POST['dir'] ); } elseif( $action == 'set_item_options') { $rsp = NAVTAJX::set_item_options( $_POST['id'], $_POST['option'] ); } elseif( $action == 'set_item_disc') { $rsp = NAVTAJX::set_item_disc( $_POST['id'] ); } elseif( $action == 'item_help') { $rsp = NAVTAJX::item_help( $_POST['id'], $_POST['isIE'] ); } elseif( $action == 'verify') { $rsp = NAVTAJX::verify_item_options( $_POST['id'] ); } elseif( $action == 'ask_remove_item') { $rsp = NAVTAJX::ask_remove_item( $_POST['id'] ); } elseif( $action == 'string_translate') { $rsp = NAVTAJX::string_translate( $_POST['text'] ); } else { navt_write_debug(NAVT_AJX, sprintf("%s::%s unhandled request: %s\n", __CLASS__, __FUNCTION__, $action), $_REQUEST); } } // send back a response navt_write_debug(NAVT_AJX, sprintf(" response: %s\n", $rsp)); header('Content-type: text/plain; charset: UTF-8'); header('Cache-Control: must-revalidate'); $expire_offset = 0; header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expire_offset) . ' GMT'); print $rsp; wp_cache_flush(); /** * NAVT configuration class * @since .96 */ class NAVTAJX { function init() { // initialize the class global $icfg, $gcfg, $navt_blank, $checkit, $selected; $icfg = NAVT::get_option(ICONFIG); // item configurations (includes group membership) $gcfg = NAVT::get_option(GCONFIG); // group configurations navt_loadtext_domain(); $navt_blank = NAVT::get_url() ."/" . IMG_BLANK; $checkit = "checked='checked'"; $selected = "selected='selected'"; //navt_write_debug(NAVT_AJX, sprintf("%s\n", __FUNCTION__), $gcfg); //navt_write_debug(NAVT_AJX, sprintf("%s\n", __FUNCTION__), $icfg); navt_write_debug(NAVT_AJX, sprintf("\n%s::%s configurations loaded\n", __CLASS__, __FUNCTION__)); return; } /** * Translate a string and send it back * * @param string $text * @return string json */ function string_translate($text) { $o = __($text, 'navt_domain'); return( NAVTAJX::mk_json_str(array('rc' => 'ok', 'text' => $o)) ); } /** * Returns help text * * @param string $subject - help subject * @param string $tab - one of the group options tabs * @return string json */ function help($subject, $ltIe7) { navt_write_debug(NAVT_AJX, sprintf("%s::%s subject %s\n", __CLASS__, __FUNCTION__, $subject )); global $navt_blank; $html = __('** Help does not exist for that subject **', 'navt_domain'); $c = 'ok'; $ex = (($ltIe7) ? 'gif' : 'png'); $h = 450; $w = 750; if( $subject == 'assets' ) { $pages = 2; $title = __('NAVT Assets', 'navt_domain'); // page 1 $p1 = "

" . __('The Asset Panel', 'navt_domain')."

" . __("The NAVT asset panel gives you the ability to create navigation items from the various resources you've created in Word Press. NAVT refers to your pages, categories, user's and other items as assets. The panel places each resource into the appropriate asset group. Groups are identified by type.", 'navt_domain')."

  1. ".__("The location where unassigned assets are created. This area is typically grayed out until one or more navigation items are created. All newly created items will appear in this section.", 'navt_domain')."
  2. ".__("Icons indicate the type of resource contained in the listbox below it. Icons and listboxes exist for Pages, Categories, User's and Other items.", 'navt_comain')."
  3. ".__('The list of assets of the type indicated. Clicking an item within the listbox will create a copy of the item and place it in the unassigned area at the top.', 'navt_domain')."
"; // page 2 $p2 = "

".__('Creating Assets', 'navt_domain')."

".__('This example illustrates what happened when the About page entry was selected.', 'navt_domain')."

  1. ".__('About Page selected by clicking the name in the listbox.', 'navt_domain')."
  2. ".__('A copy of the About Page navigation item is created.', 'navt_domain')."
  3. ".__('The navigation item appears in the unassigned area.', 'navt_domain')."
  4. ".__("The About Page navigation item can be deleted by clicking the item's delete button.", 'navt_domain')."
  5. ".__('The navigation item can be dragged and dropped to a navigation group by moving the item from the unassigned group.', 'navt_domain')."

".__('Any number of the same navigation items may be created and placed into different navigation groups. Each item (even if they represent identicle items) have separately configurable options. Item option setting for one item will not effect the option settings for another.', 'navt_domain')."

"; } elseif( $subject == 'new_group' ) { $pages = 2; $h = 500; $title = __('NAVT Groups and Items', 'navt_domain'); // page 1 $p1 = "

".__('Navigation Groups', 'navt_domain')."

".__("NAVT groups are a simple collection of navigation items composed from the pages, categories, users and other items that you've created in your WordPress blog. All available items are shown in the assets panel on the left side of the screen (see asset help). Items are divided into types and appear within separate lists.", 'navt_domain')."

".__('Creating Groups', 'navt_domain')."

".__("Navigation groups are created by entering a group name into the group name textbox in the NAVT toolbar at the top of the screen. After entering the name, click the create button. The group name you enter must begin with an alphabetic character and it cannot contain spaces. Group names are limited in size to no more than 10 characters. All group names must be unique. After creating the group, a new (and empty) group container will appear to the right of the assets panel. The group name will appear at the top of the group container.", 'navt_domain')."

".__('Group Toolbar', 'navt_domain')."

".__('The group toolbar (shown on the right) contains three icons in addition to the area for the group name:', 'navt_domain')."

  1. ".__('A lock icon - used to prevent group changes.', 'navt_domain')."
  2. ".__('The name of the navigation group.', 'navt_domain')."
  3. ".__('A trashcan - used to delete the entire group.', 'navt_domain')."
  4. ".__('A gear icon - used for setting group options.', 'navt_domain')."
".__(
"; // page 2 $p2 = "

".__('Creating Items', 'navt_domain')."

".__("Navigation items are created by clicking on the name of an item listed in the Pages, Categories, User's and Others listboxes in the assets panel. When you select and item, a copy of the item will appear in unassigned section at the top of the assets panel. The item may then be dragged and dropped into any one of the group containers you previously created.", 'navt_domain')."

".__("More than one of the same item may be created and placed into the same or into a different group. Every item (even the same items) may be configured to have different options.", 'navt_domain')."

".__('Item Tools', 'navt_domain')."

".__('Each item contains a number of management tools.', 'navt_domain')."

".__(
  1. ".__("The item alias - the name of the item as it will appear in the navigation list. Click the item alias to open the item's option box.", 'navt_domain')."
  2. ".__('The item icon - represents the type of item (page, category, user or other). The icon is used to move the item from group to group.', 'navt_domain')."
  3. ".__('Connect/Disconnect icon - disconnecting the item means that the item remains in the group, however, the item will not be included in the output navigation list created for the web site. Connecting the item means that the item will be included in the output navigation list. This feature is used for temporarily eliminating an item without removing it from the group.', 'navt_domain')."
  4. ".__('Item removal icon - this icon is used to delete the item from the group.', 'navt_domain')."
  5. ".__('Hierarchical control arrows - used for moving the item to the left or right to indicate parent/child relationships.', 'navt_domain')."
"; } elseif( $subject == 'backup' ) { // backup/restore $pages = 1; $h = 200; $title = __('Backup/Restore', 'navt_domain'); // page 1 $p1 = "

".__('This feature is not yet implemented.', 'navt_domain')."

"; } elseif( $subject == 'group-options-tab-0' ) { $pages = 3; $h = 625; $title = __('Configuring Group Options', 'navt_domain'); // page 1 $p1 = "

".__('Theme Integration', 'navt_domain')."

".__("This section enables you to integrate navigation groups into a Word Press theme by combining an xpath expression with one of the actions from the action list. For example, if you wanted to insert the navigation group above a division in your theme where the id of the division were named header then you would enter: #header into the xpath textbox. A hash character must proceed an id to indicate that the xpath contains a selector id. The navigation group can be inserted above, below, at the top or at the bottom of the location expressed in the xpath text box.

The navigation group can be preceeded by any number of additional HTML tags. HTML tags can contain an id and/or CSS classes. Id and class names must be enclosed within double quotes. Ending tags must be entered if beginning tags are used.", 'navt_domain')."

" . "

".__('CSS Styles', 'navt_domain')."

".__("NAVT provides several CSS classes to the HTML it creates for your web site. Classes are used to assist you in styling your navigation groups. In addition, you have the choice of either applying native Word Press styles or not using any styles at all. Your own styles can exclusively used by selecting 'Do not apply CSS classes' and adding 'Apply the CSS information below to this navigation group", 'navt_domain')."

".__('User Styles', 'navt_domain')."

".__('By default, NAVT constructs navigation groups for your web site by building one or more unordered lists from the contents of the group. The number of unordered tag groups is dependent on whether or not parent/child relationships exist amoung the various navigation items in the list. Lists begin with a standard UL tag followed by one or more LI tags or nested UL tags contained within an LI tag.', 'navt_domain')."

".__('To add CSS classes, enter the class names in the textboxes provided. Multiple class names can be entered (per tag) by separating each class name with a space. No more than one selector name can be entered into the UL Selector ID textbox.', 'navt_domain')."

"; // page 2 $p2 = "

".__('Show only top-level anchors on page', 'navt_domain')."

".__("When checked, the option Show only top-level anchors on page (hide hierarchy) will display only the links to the child pages of the current page. If a child page contains children of it's own, those anchors will only be shown when the child page is viewed. For example, if you created the following navigation group:", 'navt_domain')."

".__('The Home Page would only display a navigation list containing Item 1 and Item 2. Their respective child links would not be visible. If you clicked Item 1, the newly displayed blog page would show the navigation links for Item 1a and Item 1b. The navigation list shown for Item 2 would contain only Item 2a.', 'navt_domain')."

".__('The option has an additional feature: Add page return to list. If this is checked, NAVT will add an additional link to the child navigation list allowing the user to return to the parent page.', 'navt_domain')."

".__('Show breadcrumb navigation', 'navt_domain')."

".__('Selecting this option will cause NAVT to add a breadcrumb path to the currently displayed page above the navigation list. For example, a user currently viewing blog page Item 1a would see the breadcrumb trail Home » Item 1 » Item 1a. Selecting a link in the breadcrumb trail will take the user to the previously viewed blog page. The path can be easily styled (using CSS) to appear anywhere on the page using absolute positioning.', 'navt_domain')."

"; // page 3 $p3 = "

".__('Create navigation list using HTML select', 'navt_domain')."

".__("Selecting this option will turn your navigation list into a Drop Down list of navigation items constructed using a HTML SELECT statement. This should not be confused with Drop Down lists produced by CSS. A typical Drop Down would appear as:", 'navt_domain')."

".__("This option has the additional feature: Display: 'N' item(s) in list. This is used to force the SELECT to show a maximum number of entries. The default is 1. For example, entering the number 3 in the box will cause the Drop Down to appear as:", 'navt_domain')."

".__('Here we can see the first three available selections. In this case, the box contains more than three items so the browser adds a scrollbar on the right. This Drop Down box does not support multiple selections.', 'navt_domain')."

".__('Set navigation group to private', 'navt_domain')."

".__('This option enables you to hide all navigation items from casual viewing if the viewer is not signed into your web site. Hiding the members of navigation lists can also be done by selecting the individual privacy option for each of the navigation items. Selecting this option will also change the color of the group heading (only in the NAVT List Page) to indicate the group is set to private.', 'navt_domain')."

"; } else if( $subject == 'group-options-tab-1' ) { $pages = 1; $title = __('Configuring Display Options', 'navt_domain'); // page 1 $p1 = "

".__('Controlling Where Navigation Groups are Displayed', 'navt_domain')."

".__('The display of any Navigation group can be controlled by specifying the page types where the navigation group should appear. The Show navigation group on... area allows you to indicate whether or not the navigation group is to appear on:', 'navt_domain')."

".__('Settings for Available Posts/Pages', 'navt_domain')."

".__('Navigation groups can also be displayed (or not displayed) on all or on individually selected posts and/or pages. To display a navigation group on one or more selected posts or pages:', 'navt_domain')."

  1. ".__('Check Settings for available posts and/or Settings for available pages. If these options are not checked, the navigation group will be displayed on all single pages and single post pages.', 'navt_domain')."
  2. ".__('Select Display this navigation group only on selected posts (or pages) or Do Not Display this navigation group only on selected posts (or pages). Selecting one of these radio buttons determines whether or not the Navigation group is to be shown on or not shown on the posts or pages that you select in the relevant list box.', 'navt_domain')."

".__('Pages and posts are listed by their respective titles.', 'navt_domain')."

"; } elseif( $subject == 'itemtype-1' ) { // pages $pages = 1; $h = 550; $title = __('Configuring Page Options', 'navt_domain'); // page 1 $p1 = "

".__('Item Alias', 'navt_domain')."

".__("The label that is given to a link is called a menu item alias. The alias is what the user sees in the navigation list on the web page. The alias may differ from the title of a page. In the diagram, A points to the item alias and B points to the item's title. The title is the name you gave the page when it was created. Changing the title will not change the alias you assigned nor will changing the alias change the page title. Item C is the icon used to signify a page.", 'navt_domain')."

".__('Options for Pages', 'navt_domain')."

page options
  1. @aliasInfo@
  2. @anchorInfo@
  3. @cssClassInfo@
  4. @privateInfo@
  5. @noFollowInfo@
"; } elseif( $subject == 'itemtype-2' ) { // Categories $pages = 1; $h = 675; $title = __('Configuring Category Options', 'navt_domain'); // page 1 $p1 = "

".__('Item Alias', 'navt_domain')."

".__("The label that is given to a link is called a menu item alias. The alias is what the user sees in the navigation list on the web page. The alias may differ from the category name. In the diagram, A points to the item alias and B points to the item's title. The title is the name you gave the category when it was created. Changing the title will not change the alias you assigned nor will changing the alias change the category title. Item C is the icon used to signify a category.", 'navt_domain')."

".__('Options for Categories', 'navt_domain')."

category options
  1. @aliasInfo@
  2. @anchorInfo@
  3. @cssClassInfo@
  4. ".__('Show in WP category list. By default NAVT will prevent a category that has been used in a NAVT navigation list from also appearing in a category list generated by Word Press. Check this option if you want the category displayed in both locations.', 'navt_domain')."
  5. ".__('Append post count - NAVT appends the number of posts contained in the category to the category name.', 'navt_domain')."
  6. ".__("Show if Empty - causes the category link to appear even if it doesn't contain any posts.", 'navt_domain')."
  7. ".__('Use description as tooltip - Uses the description of the category as the mouse hover tooltip.', 'navt_domain')."
  8. @privateInfo@
  9. @noFollowInfo@
"; } elseif( $subject == 'itemtype-3-'.HOMEIDN ) { // home item $pages = 1; $title = __('Configuring Home Page Options', 'navt_domain'); // page 1 $p1 = "

".__('Item Alias', 'navt_domain')."

".__('The label that is given to a link is called a menu item alias. The alias is what the user sees in the navigation list on the web page. The alias may differ from the Home title. In the diagram, A points to the item alias and B points to the Home title. Item C is the icon used to signify the Home navigation item.', 'navt_domain')."

".__('Options', 'navt_domain')."

".__(
  1. @aliasInfo@
  2. @anchorInfo@
  3. @cssClassInfo@
  4. @noFollowInfo@
"; } elseif( $subject == 'itemtype-3-'.LOGINIDN ) { // admin item $pages = 1; $h = 715; $w = 800; $title = __('Configuring SignIn Options', 'navt_domain'); // page 1 $p1 = "

".__('Sign in/Register Item', 'navt_domain')."

".__('This item is equivalent to the Word Press sign-on/register anchors as part of the Word Press meta data. The anchor presented depends on whether or not the user has signed into the web site. When signed in, the anchor allows them to sign out; if not signed in and the Word Press Membership option: anyone can register is checked, the anchor will allow the user to register or sign in.', 'navt_domain')."

".__('Item Alias', 'navt_domain')."

".__('The label that is given to a link is called a menu item alias. The alias is what the user sees in the navigation list on the web page. The alias may differ from the sign-in title. In the diagram, A points to the item alias and B points to the sign-in title. Item C is the icon used to signify the sign-in administration item.', 'navt_domain')."

".__('Options for Site Administration', 'navt_domain')."

".__(
  1. @aliasInfo@
  2. @anchorInfo@
  3. @cssClassInfo@
  4. ".__('Create sign-in form - selecting this will create a small sign-in form on the web site.', 'navt_domain')."
  5. ".__('Use referral page redirect - After signing in, the user remains on the page where they signed in.', 'navt_domain')."
  6. ".__('Use URL redirect - When checked, the user is redirected to the URL that is contained in the redirect URL textbox.', 'navt_domain')."
  7. ".__('Redirect URL text box - enables you to send the signed in user to another page on your web site. Enter a complete URL in this box.', 'navt_domain')."
  8. @privateInfo@
  9. @noFollowInfo@
"; } elseif( $subject == 'itemtype-4' ) { // divider item $pages = 1; $h = 590; $title = __('Configuring Divider Options', 'navt_domain'); // page 1 $p1 = "

".__('Divider Items', 'navt_domain')."

".__("A divider is primarily designed to separate navigation lists into groups of related items. A divider can be inserted between elements to provide an empty space, a horizontal line or a plain text title. The menu item alias serves as the title when the divider type is set to 'plain text'.", 'navt_domain')."

".__('Item Alias', 'navt_domain')."

".__('The label that is given to a link is called a menu item alias. The alias is what the user sees in the navigation list on the web page. The alias is used as a title or header when the divider type is set to plain text. No alias is displayed when the divider type is set to either empty space horizontal rule. In the diagram, A points to the item alias and B points to the List Divider title. Item C is the icon used to signify the dvider navigation item.', 'navt_domain')."

".__('Divider Options', 'navt_domain')."

".__(
  1. @aliasInfo@
  2. @anchorInfo@
  3. @cssClassInfo@
  4. ".__('Divider type - the type of divider to create.', 'navt_domain')."
  5. @privateInfo@
"; } elseif( $subject == 'itemtype-5' ) { // elink item $pages = 1; $h = 660; $title = __('Configuring URI Options', 'navt_domain'); // page 1 $p1 = "

".__('URI Items', 'navt_domain')."

".__("A Uniform Resource Identifier (URI), is a compact string of characters used to identify or name a resource. The main purpose of this identification is to enable interaction with representations of the resource over a network, typically the World Wide Web, using specific protocols. URIs are defined in schemes defining a specific syntax and associated protocols. URI's supported by NAVT are limited to: http:// for identifying both internal or extern web site pages and mailto: for providing an anchor for sending email.", 'navt_domain')."

".__('Item Alias', 'navt_domain')."

".__("The label that is given to a link is called a menu item alias. The alias is what the user sees in the navigation list on the web page. In the diagram, A points to the item alias and B points to the item's title. The title will always be User defined URI. Item C is the icon used to signify a URI item.", 'navt_domain')."

".__('URI Options','navt_domain')."

".__(
  1. @aliasInfo@
  2. @anchorInfo@
  3. @cssClassInfo@
  4. ".__('URL text box - a complete resource identifier (i.e. http:// or mailto:)', 'navt_domain')."
  5. ".__('Open in same window - Opens in the same window, otherwise opens the resource in a new window.','navt_domain')."
  6. @privateInfo@
  7. @noFollowInfo@
"; } elseif( $subject == 'itemtype-6' ) { // author item $pages = 1; $h = 630; $title = __('Configuring Registered User Options', 'navt_domain'); // page 1 $p1 = "

".__('Item Alias','navt_domain')."

".__("The label that is given to a link is called a menu item alias. The alias is what the user sees in the navigation list on the web page. The alias may differ from the user display name. In the diagram, A points to the item alias and B points to the user's signin name. Changing the user's display name will not change the alias you assigned nor will changing the alias change the display name. Item C is the icon used to signify a registered user. ", 'navt_domain')."

".__('Options for Users','navt_domain')."

".__(
  1. @aliasInfo@
  2. ".__('Show avatar - select this to place an avatar next to the user name','navt_domain')."
  3. ".__('Use default avatar - allows you to use one of the default avatars in the drop down list.','navt_domain')."
  4. ".__('A list of default avatars to choose from. The selected avatar is displayed above the drop down box.','navt_domain')."
  5. ".__('User avatar URI - this is active only if use default avatar is not checked. Enter a qualified URI for the avatar to be used for this user.', 'navt_domain')."
  6. ".__('Show if no posts - When selected, NAVT will show this user if the user has not posted on the web site.','navt_domain')."
  7. ".__('Append author post count - Appends the number of posts to the users anchor.','navt_domain')."
  8. ".__("Include web site - If you have entered a web site address to the user's profile, it will be included as an anchor.",'navt_domain')."
  9. ".__('Include user bio - If you have entered a bio for this user, the text will be included.','navt_domain')."
  10. ".__("Include user email - selecting this will add the user's email address (mailto:) format.", 'navt_domain')."
  11. ".__('Hide link text - Available only if you are using an avatar. Selecting this will hide all user anchor text.','navt_domain')."
  12. @privateInfo@
  13. @noFollowInfo@
"; } if( $c == 'ok' ) { $html = ''; if( $pages ) { for( $p = 1; $p <= $pages; $p++ ) { // add content $html .= "
1) ? "style='display:none;'" : '') . ">". "@content-p$p"."@
"; $html .= "
"; // add page buttons if( $p < $pages ) { $html .= "". "

" . __('Next', 'navt_domain') . "

"; } if( $p > 1 ) { $html .= ""; } $html .= "
"; } } /** * Complete the page */ $html = str_replace('@content-p1@', $p1, $html); $html = str_replace('@content-p2@', $p2, $html); $html = str_replace('@content-p3@', $p3, $html); $html = str_replace('@content-p4@', $p4, $html); $html = str_replace('@content-p5@', $p5, $html); $html = str_replace('@content-p6@', $p6, $html); $html = str_replace('@path@', NAVT::get_url(), $html); /** * Substitutions for common options */ $html = str_replace('@aliasInfo@', __("The item alias edit box. Use this to change the name that appears in the navigation menu.", 'navt_domain'), $html); $html = str_replace('@anchorInfo@', __("Anchor type - Choose the type of link you want to appear on the web page. The choices are:", 'navt_domain')."".__('All links that contain graphics require a CSS class that will be applied to the graphic container.', 'navt_domain'), $html); $html = str_replace('@cssClassInfo@', __("CSS class for graphic - used only with anchors that use graphics. Enter the name of the class to be used.", 'navt_domain'), $html); $html = str_replace('@noFollowInfo@', __("Add rel=nofollow - nofollow is a non-standard HTML attribute value used to instruct search engines that a hyperlink should not influence the link target's ranking in the search engine's index.", 'navt_domain')." ".__('see definition', 'navt_domain')."", $html); $html = str_replace('@privateInfo@', __("Set to private - if checked, the anchor is visible only to those that are signed into your web site.", 'navt_domain'), $html); } navt_write_debug(NAVT_AJX, sprintf("%s::%s %s\n", __CLASS__, __FUNCTION__, $html)); // open a window return( NAVTAJX::mk_json_str(array('rc' => $c, 'width' => $w, 'height' => $h, 'title' => $title, 'html' => $html)) ); } /** * Add a new group * * @param string $group_name * @return string (json) * @since .96 */ function add_new_group($group_name) { navt_write_debug(NAVT_AJX, sprintf("%s::%s group %s\n", __CLASS__, __FUNCTION__, $group_name)); global $icfg, $gcfg; $text = __('add group error', 'navt_domain'); $rc = NAVTAJX::mk_json_str(array('rc' => 'error', 'type' => 'group_add', 'msg' => $text)); // sanitize the name $group_name = NAVT::clean_group_name($group_name); if('' == $group_name ) { $text = __('invalid name', 'navt_domain'); $rc = '{"rc":"error", "type":"name", "msg":"'.$text.'"}'; } else { //first letter can't be numeric $c = substr($group_name, 0, 1); if(is_numeric($c)) { $text = __('invalid name', 'navt_domain'); $rc = '{"rc":"error", "type":"name", "msg":"'.$text.'"}'; } else { // check for a duplicate if( NAVTAJX::check_for_duplicate_group($group_name) ) { $text = __('duplicate name', 'navt_domain'); $rc = NAVTAJX::mk_json_str(array('rc' => 'error', 'type' => 'name', 'msg' => $text)); } else { $groups = $icfg; $n_icfg = array(); if(is_array($groups)) { foreach( $groups as $group => $members ) { $n_icfg[$group] = $members; } $scheme = NAVT::get_option(SCHEME); $scheme = ($scheme + 1 > 6) ? 1: $scheme + 1; $gcfg[$group_name] = NAVT::mk_group_config(); $n_icfg[$group_name] = array(); NAVT::update_option(SCHEME, $scheme); NAVT::update_option(ICONFIG, $n_icfg); NAVT::update_option(GCONFIG, $gcfg); $rc = NAVTAJX::mk_json_str(array('rc' => 'ok', 'name' => $group_name, 'scheme' => $scheme)); } } } } navt_write_debug(NAVT_AJX, sprintf("%s::%s rc=%s\n", __CLASS__, __FUNCTION__, $rc)); return($rc); } /** * Rename a group * * @param string $target_group * @param string $new_name * @return string (json) * @since .96 */ function rename_group($target_group, $new_name) { navt_write_debug(NAVT_AJX, sprintf("%s::%s old %s, new %s\n", __CLASS__, __FUNCTION__, $target_group, $new_name)); global $icfg, $gcfg; $n_gcfg = $n_icfg = array(); $text = __("Problem renaming group"); $rc = NAVTAJX::mk_json_str(array('rc' => 'error', 'type' => 'rename', 'msg' => $text)); // sanitize the name $new_name = NAVT::clean_group_name($new_name); if('' == $new_name ) { $text = __('invalid name', 'navt_domain'); $rc = '{"rc":"error", "type":"rename", "msg":"'.$text.'"}'; } else { // check for a duplicate if( NAVTAJX::check_for_duplicate_group($new_name) ) { $text = __('duplicate name', 'navt_domain'); $rc = NAVTAJX::mk_json_str(array('rc' => 'error', 'type' => 'rename', 'msg' => $text, 'name' => $target_group)); } else { if(is_array($icfg)) { $rc = NAVTAJX::mk_json_str(array('rc' => 'ok', 'old_name' => $target_group, 'new_name' => $new_name)); foreach( $icfg as $group => $members ) { if( $group != $target_group ) { $n_icfg[$group] = $members; } else { foreach($members as $id => $member) { $member[GRP] = $new_name; $n_icfg[$new_name][$id] = $member; } } } foreach( $gcfg as $key => $group_data ) { if( $key != $target_group ) { $n_gcfg[$key] = $group_data; } else { $n_gcfg[$new_name] = $group_data; } } if( count($n_icfg) > 0 ) { NAVT::update_option(ICONFIG, $n_icfg); NAVT::update_option(GCONFIG, $n_gcfg); } } } } navt_write_debug(NAVT_AJX, sprintf("%s::%s rc=%s\n", __CLASS__, __FUNCTION__, $rc)); return($rc); } /** * Ask to remove a group - returns a prompt for display * * @param string $group * @return string (json) * @since .96 */ function ask_remove_group($group) { navt_write_debug(NAVT_AJX, sprintf("%s::%s group %s\n", __CLASS__, __FUNCTION__, $group)); global $navt_blank; $name = strtolower($group); $title = __('Delete this group?', 'navt_domain'); $html = "

".__("Select Ok to remove group '$name'.", 'navt_domain')."

". "
". "

".__('Ok', 'navt_domain')."

". "

".__('Cancel', 'navt_domain')."

". "
"; $rc = NAVTAJX::mk_json_str(array('rc' => 'ok', 'html' => $html, 'width' => 400, 'height' => 125, 'title' => $title, 'group' => strtoupper($name))); return($rc); } /** * Remove a group * * @param string $group * @return string (json) * @since .96 */ function remove_group($group) { navt_write_debug(NAVT_AJX, sprintf("%s::%s group %s\n", __CLASS__, __FUNCTION__, $group)); $rc = NAVTAJX::mk_json_str(array('rc' => 'ok', 'group' => strtoupper($group))); NAVTAJX::remove_configured_group($group); return($rc); } /** * Reorder the items in all groups - rebuilds the configuration arrays * to represent item membership and position of each item. New items * are added here by way of discovery. * * @param array $order - 2d array indexed by group and selector id * @return string (json) * @since .96 */ function reorder_groups($order) { navt_write_debug(NAVT_AJX, sprintf("%s::%s\n", __CLASS__, __FUNCTION__), $order); global $icfg, $gcfg; $rc = NAVTAJX::mk_json_str(array('rc' => 'ok')); $n_icfg = $n_gcfg = array(); if( !is_array($order) ) { // array is empty - no groups left NAVT::update_option(ICONFIG, array()); NAVT::update_option(GCONFIG, array()); } else { $configured_ids = NAVTAJX::get_configured_items(); $assets = NAVT::get_option(ASSETS); foreach( $order as $group => $member ) { foreach( $member as $idx => $id ) { if( !array_key_exists($id, $configured_ids) ) { navt_write_debug(NAVT_AJX, sprintf("%s:%s new item: group %s, id %s\n", __CLASS__, __FUNCTION__, $group, $id)); if( !in_array($id, $icfg) ) { // a-type-idn--xxxx where 'xxxx' is a unique instance number //$t[ 0 ][ 1 ] $t = split('--', $id); // remove the instance number // a-type-idn //$t[0][ 1 ][2] $t = split('-', $t[0]); // get the type and idn $typ = $t[1]; $idn = $t[2]; $asset = $assets[$typ][$idn]; $configured_ids[$id] = $asset; navt_write_debug(NAVT_AJX, sprintf("\t%s::%s new item added\n", __CLASS__, __FUNCTION__)); } } // update this item $item = $configured_ids[$id]; $item[GRP] = $group; $n_icfg[$group][$id] = $item; if( isset($gcfg[$group]) ) { $n_gcfg[$group] = $gcfg[$group]; } } } } if( count($n_icfg) > 0 ) { NAVT::update_option(ICONFIG, $n_icfg); NAVT::update_option(GCONFIG, $n_gcfg); $icfg = $n_icfg; $gcfg = $n_gcfg; } navt_write_debug(NAVT_AJX, sprintf("%s::%s new\n", __CLASS__, __FUNCTION__), $n_icfg); navt_write_debug(NAVT_AJX, sprintf("%s::%s rc=%s\n", __CLASS__, __FUNCTION__, $rc)); return($rc); } /** * Add an asset to a group * * @param string $id * @param string $group * @return string (json) * @since .96 */ function add_group_item($id, $group) { navt_write_debug(NAVT_AJX, sprintf("%s::%s group %s, id %s\n", __CLASS__, __FUNCTION__, $group, $id)); global $icfg; $rc = NAVTAJX::mk_json_str(array('rc' => 'ok')); $assets = NAVT::get_option(ASSETS); if( !in_array($id, $icfg) ) { // a-type-idn--xxxx where 'xxxx' is a unique instance number //$t[ 0 ][ 1 ] $t = split('--', $id); // a-type-idn //$t[0][ 1 ][2] $t = split('-', $t[0]); // get the type and idn $typ = $t[1]; $idn = $t[2]; $asset = $assets[$typ][$idn]; $n_icfg = NAVTAJX::insert_configured_item($group, $id, $asset); if( count($n_icfg) > 0 ) { NAVT::update_option(ICONFIG, $n_icfg); } navt_write_debug(NAVT_AJX, sprintf("%s::%s new\n", __CLASS__, __FUNCTION__), $n_icfg); } navt_write_debug(NAVT_AJX, sprintf("%s::%s rc=%s\n", __CLASS__, __FUNCTION__, $rc)); return($rc); } /** * Toggles group locking option * * @param string $group * @param string $option * @return json string * @since .96 */ function toggle_group_option($group, $option) { navt_write_debug(NAVT_AJX, sprintf("%s::%s group %s, option %s\n", __CLASS__, __FUNCTION__, $group, $option)); global $gcfg; $group = strtolower($group); $rc = NAVTAJX::mk_json_str(array('rc' => 'ok', 'name' => $group, 'option' => '@STATE@')); $opts = intval($gcfg[$group]['options'],10) & 0xffff; $bit = 0; if( $option == 'lock') $bit = ISLOCKED; if( $bit != 0 ) { $opts = ($opts & $bit ? $opts - $bit: $opts + $bit); $gcfg[$group]['options']= $opts; NAVT::update_option(GCONFIG, $gcfg); } $rc = str_replace('@STATE@', (($opts & $bit) ? '1': '0'), $rc); return($rc); } /** * Returns group options * * @param string $group * @param string $option * @param string $value * @return json string * @since .96 */ function get_group_options($group, $active_tab='tab-0') { navt_write_debug(NAVT_AJX, sprintf("%s::%s group %s\n", __CLASS__, __FUNCTION__, $group)); global $gcfg, $navt_blank; $tab = split('-',$active_tab); $name = strtolower($group); $options = intval($gcfg[$name]['options'],10) & 0xffff; $select_size = (intval($gcfg[$name]['select_size'],10) & 0xffff); $display = $gcfg[$name]['display']; $css_id = $gcfg[$name]['css']['ulid']; $css_ul = $gcfg[$name]['css']['ul']; $css_li = $gcfg[$name]['css']['li']; $css_li_current = $gcfg[$name]['css']['licurrent']; $css_li_parent = $gcfg[$name]['css']['liparent']; $css_li_parent_active = $gcfg[$name]['css']['liparent_active']; $isprivate_group = ((intval($options,10) & ISPRIVATE) ? 1: 0); $theme_xpath = $gcfg[$name]['selector']['xpath']; $theme_option = intval($gcfg[$name]['selector']['option'], 10); $before_group = $gcfg[$name]['selector']['before']; $after_group = $gcfg[$name]['selector']['after']; $html = "

".__('Options for group ', 'navt_domain') ."'$name'

" . "
" . "
" . "
" . "
" . "
" . NAVTAJX::get_options_for_display($options, $select_size, $css_id, $css_ul, $css_li, $css_li_current, $css_li_parent, $css_li_parent_active, $theme_xpath, $theme_option, $before_group, $after_group) . "
" . "
" . NAVTAJX::get_other_for_display($display) . NAVTAJX::get_posts_for_display($display) . NAVTAJX::get_pages_for_display($display) . "
" . "
".__('save', 'navt_domain')."" . "" . __('save/close') . "
" . "
"; // substitutions $html = str_replace('@NS@', 'navt_ns', $html); $html = str_replace('@GROUPNAME@', $group, $html); $html = str_replace('@SRC@', $navt_blank, $html); $rc = NAVTAJX::mk_json_str(array('rc' => 'ok', 'name' => $name, 'html' => $html, 'isprivate' => $isprivate_group, 'width' => 605)); return($rc); } /** * Save group options * * @param string $group * @param array $display * @param array $options * @param array $page_list * @param array $post_list * @return string (json) * @since .96 */ function save_group_options($group, $group_options, $display, $page_list, $post_list, $save_type, $active_tab) { navt_write_debug(NAVT_AJX, sprintf("%s::%s group %s\n", __CLASS__, __FUNCTION__, $group)); navt_write_debug(NAVT_AJX, sprintf("%s::%s group_options\n", __CLASS__,__FUNCTION__), $group_options); navt_write_debug(NAVT_AJX, sprintf("%s::%s display_options\n", __CLASS__, __FUNCTION__), $display); navt_write_debug(NAVT_AJX, sprintf("%s::%s pages\n", __CLASS__, __FUNCTION__), $page_list); navt_write_debug(NAVT_AJX, sprintf("%s::%s posts\n", __CLASS__, __FUNCTION__), $post_list); global $gcfg, $icfg; $name = $group; if( isset($group) ) { if( $group != $group_options['name'] ) { $rc = NAVTAJX::rename_group($group, $group_options['name']); if((strstr($rc, 'error')) !== false ) { $err = $rc; } else { // refresh these $name = $group_options['name']; $icfg = NAVT::get_option(ICONFIG); $gcfg = NAVT::get_option(GCONFIG); } } } if( !isset($err) && count($group_options) > 0 ) { $n_gcfg = $gcfg; $isprivate_group = 0; $opts = intval($n_gcfg[$group]['options'],10) & 0xffff; $lock_state = (($opts & ISLOCKED) ? ISLOCKED: 0); $n_gcfg[$name]['display']['show_on'] = 0; $n_gcfg[$name]['options'] = $lock_state; $n_gcfg[$name]['css']['ul'] = $n_gcfg[$name]['css']['li'] = $n_gcfg[$name]['css']['ulid'] = $n_gcfg[$name]['css']['licurrent'] = $n_gcfg[$name]['css']['liparent'] = $n_gcfg[$name]['css']['liparent_active'] = ''; $n_gcfg[$name]['display']['posts']['ids'] = $n_gcfg[$name]['display']['pages']['ids'] = array(); foreach($group_options as $key => $value) { switch( $key ) { case 'style_selection': { $n_gcfg[$name]['options'] |= (intval($value,10) & 0xffff); break; } case 'add_user_classes': { $n_gcfg[$name]['options'] |= USE_USER_CLASSES; break; } case 'is_private': { $n_gcfg[$name]['options'] |= ISPRIVATE; $isprivate_group = 1; break; } case 'use_select': { $n_gcfg[$name]['options'] |= HAS_DD_OPTION; break; } case 'select_size': { $n_gcfg[$name]['select_size'] = (intval($value,10) & 0xffff); break; } case 'show_breadcrumbs' : { $n_gcfg[$name]['options'] |= ADD_BREADCRUMBS; break; } case 'set_on_posts': { $ids = array(); $n_gcfg[$name]['display']['show_on'] |= SET_ON_POSTS; $v = $display['posts']['on_selected']; $n_gcfg[$name]['display']['posts']['on_selected'] = $v; $n_gcfg[$name]['display']['show_on'] |= ( ( $v == 'show' ) ? SHOW_ON_POSTS: 0); if( count($post_list) > 0 ) { foreach( $post_list as $id ) { $ids[$id] = $v; } $n_gcfg[$name]['display']['posts']['ids'] = $ids; } else { // no posts were specified - default is to show on all posts // turn off SET_ON_POSTS bit. $opt = (intval($n_gcfg[$name]['display']['show_on'],10)); $opt -= SET_ON_POSTS; $n_gcfg[$name]['display']['show_on'] = $opt; $n_gcfg[$name]['display']['posts']['on_selected'] = 'show'; } break; } case 'set_on_pages': { $ids = array(); $n_gcfg[$name]['display']['show_on'] |= SET_ON_PAGES; $v = $display['pages']['on_selected']; $n_gcfg[$name]['display']['pages']['on_selected'] = $v; $n_gcfg[$name]['display']['show_on'] |= ( ( $v == 'show' ) ? SHOW_ON_PAGES: 0); if( count($page_list) > 0 ) { foreach( $page_list as $id ) { $ids[$id] = $v; } $n_gcfg[$name]['display']['pages']['ids'] = $ids; } else { // no pages were specified - default is to show on all pages // turn off SET_ON_PAGES bit. $opt = (intval($n_gcfg[$name]['display']['show_on'],10)); $opt -= SET_ON_PAGES; $n_gcfg[$name]['display']['show_on'] = $opt; $n_gcfg[$name]['display']['pages']['on_selected'] = 'show'; } break; } case 'fold_pages': { $n_gcfg[$name]['options'] |= PAGE_FOLDING; break; } case 'add_page_return': { $n_gcfg[$name]['options'] |= ADD_PAGE_RETURN; break; } case 'ulselector': { $ulid = strip_tags($value); $ulid = stripslashes($ulid); $n_gcfg[$name]['css']['ulid'] = $ulid; break; } case 'licurrent': { $li_current = strip_tags($value); $li_current = stripslashes($li_current); $n_gcfg[$name]['css']['licurrent'] = $li_current; break; } case 'liparent': { $li_parent = strip_tags($value); $li_parent = stripslashes($li_parent); $n_gcfg[$name]['css']['liparent'] = $li_parent; break; } case 'liparent_active': { $li_parent_active = strip_tags($value); $li_parent_active = stripslashes($li_parent_active); $n_gcfg[$name]['css']['liparent_active'] = $li_parent_active; break; } case 'ulclass': { $ulclass = strip_tags($value); $ulclass = stripslashes($ulclass); $n_gcfg[$name]['css']['ul']= $ulclass; break; } case 'liclass': { $liclass = strip_tags($value); $liclass = stripslashes($liclass); $n_gcfg[$name]['css']['li'] = $liclass; break; } case 'theme_xpath': { $n_gcfg[$name]['options'] |= HAS_XPATH; $v = strip_tags($value); $v = stripslashes($v); $n_gcfg[$name]['selector']['xpath'] = $v; break; } case 'selector_action': { $n_gcfg[$name]['selector']['option'] = intval($value, 10); break; } case 'before_group': { $n_gcfg[$name]['selector']['before'] = html_entity_decode($value, ENT_QUOTES); break; } case 'after_group': { $n_gcfg[$name]['selector']['after'] = html_entity_decode($value, ENT_QUOTES); break; } }// end switch } if( !($n_gcfg[$name]['options'] & HAS_XPATH) ) { $n_gcfg[$name]['selector']['xpath'] = $n_gcfg[$name]['selector']['before'] = $n_gcfg[$name]['selector']['after'] = ''; } $opt = (intval($n_gcfg[$name]['display']['show_on'],10)); if( !($opt & SET_ON_PAGES) ) {$opt |= SHOW_ON_PAGES;} if( !($opt & SET_ON_POSTS) ) {$opt |= SHOW_ON_POSTS;} $n_gcfg[$name]['display']['show_on'] = $opt; if( !($n_gcfg[$name]['options'] & HAS_DD_OPTION) ) { $n_gcfg[$name]['select_size'] = 1; } if( count($display) > 0 ) { if( isset($display['other']) ) { foreach( $display['other'] as $key => $value ) { if( $key == 'home' ) $n_gcfg[$name]['display']['show_on'] |= SHOW_ON_HOME; if( $key == 'search' ) $n_gcfg[$name]['display']['show_on'] |= SHOW_ON_SEARCH; if( $key == 'error' ) $n_gcfg[$name]['display']['show_on'] |= SHOW_ON_ERROR; if( $key == 'archive' ) $n_gcfg[$name]['display']['show_on'] |= SHOW_ON_ARCHIVES; if( $key == 'posts_page') $n_gcfg[$name]['display']['show_on'] |= SHOW_ON_PPAGE; if( $key == 'static_page') $n_gcfg[$name]['display']['show_on'] |= SHOW_ON_SFP; } } } } if( !isset($err) ) { // update the configuration/send back an updated window NAVT::update_option(GCONFIG, $n_gcfg); $gcfg = NAVT::get_option(GCONFIG); // refresh this if( $save_type == 0 ) { // not closing $rc = NAVTAJX::get_group_options($name, $active_tab); } else { // send back an ok with the [new?] name $rc = NAVTAJX::mk_json_str(array('rc' => 'ok', 'name' => $name, 'isprivate' => $isprivate_group)); } } navt_write_debug(NAVT_AJX, sprintf("%s::%s group settings\n", __CLASS__, __FUNCTION__), $n_gcfg[$name]); return($rc); } /** * Return the list of posts for the group display settings * * @param array $display * @return string (html) * @since .96 */ function get_posts_for_display($display) { global $wpdb, $post, $checkit, $selected; $html = ''; $show_on_posts = ((intval($display['show_on'],10) & SET_ON_POSTS) ? 1: 0); $on_selected = ((intval($display['show_on'],10) & SHOW_ON_POSTS) ? 'show':'hide'); // get published posts from the database $posts = get_posts(array('numberposts' => -1)); //navt_write_debug(NAVT_AJX, sprintf("%s::%s \n", __CLASS__, __FUNCTION__), $posts); if($posts) { $html .= "
" . "
". " ". __('Settings for available posts', 'navt_domain')." " . "

" . __("Display this navigation group only on selected posts", 'navt_domain') . "
" . " " . __("Do not display this navigation group on selected posts") . "

" . "
"; $html = str_replace('@DISABLED@', (($show_on['posts']) ? '': "disabled='disabled'"), $html); $html = str_replace('@DISABLED_CLASS@', (($show_on['posts']) ? '': "disabled"), $html); $html = str_replace('"', '"', $html); } return($html); } /** * Return the list of pages for the group display settings * * @param array $display * @return string (html) * @since .96 */ function get_pages_for_display($display) { global $wpdb, $post, $checkit, $selected; $html = ''; $show_on_pages = (intval($display['show_on'],10) & SET_ON_PAGES ? 1: 0); $on_selected = ((intval($display['show_on'],10) & SHOW_ON_PAGES) ? 'show':'hide'); // get published pages from the database $pages = get_pages(); //navt_write_debug(NAVT_AJX, sprintf("%s::%s \n", __CLASS__, __FUNCTION__), $posts); if($pages) { $html .= "
" . "
". " ". __('Settings for available pages', 'navt_domain')." " . "

" . __("Display this navigation group only on selected pages", 'navt_domain') . "
" . __("Do not display this navigation group on selected pages", 'navt_domain') . "

"; $html = str_replace('@DISABLED@', (($show_on['pages']) ? '': "disabled='disabled'"), $html); $html = str_replace('@DISABLED_CLASS@', (($show_on['pages']) ? '': "disabled"), $html); $html = str_replace('"', '"', $html); } return($html); } /** * Returns group options for option window * * @param integer $options * @return string (html) * @since .96 */ function get_options_for_display($options, $select_size, $css_id, $css_ul, $css_li, $css_li_current, $css_li_parent, $css_li_parent_active, $theme_xpath, $theme_option, $before_group, $after_group) { global $checkit, $selected; $has_no_style = (($options & HAS_NOSTYLE) ? $checkit:''); $use_wp_defaults = (($options & USE_WP_DEFAULTS) ? $checkit:''); $use_navt_classes = (($options & USE_NAVT_DEFAULTS) ? $checkit:''); $add_user_classes = (($options & USE_USER_CLASSES) ? $checkit:''); $is_select = (($options & HAS_DD_OPTION) ? $checkit:''); $is_private = (($options & ISPRIVATE) ? $checkit:''); $is_page_fold = (($options & PAGE_FOLDING) ? $checkit:''); $has_page_return = (($options & ADD_PAGE_RETURN) ? $checkit:''); $show_breadcrumbs = (($options & ADD_BREADCRUMBS) ? $checkit:''); $theme_insert_before = (($theme_option == INS_BEFORE) ? $selected:''); $theme_insert_after = (($theme_option == INS_AFTER) ? $selected:''); $theme_at_top = (($theme_option == INS_AT_TOP) ? $selected:''); $theme_at_bottom = (($theme_option == INS_AT_BOTTOM) ? $selected:''); $theme_replace_with = (($theme_option == REPLACE_WITH) ? $selected:''); $html = "
".__('Group Name', 'navt_domain') .": ". "". "
" . "
".__('Theme Integration', 'navt_domain')."" . "".__('Theme xpath', 'navt_domain').": " . "". " ".__('Action', 'navt_domain').": ". "". "

".__('Add tags before navigation group', 'navt_domain').": ". "". "

".__('Add tags after navigation group', 'navt_domain').":
". "". "

". ""; return($html); } /** * Returns 'show on' options beyond pages/posts * * @param array $display * @return string (html) * @since .96 */ function get_other_for_display($display) { global $checkit; $show_on = array(); $show_on['archives'] = intval($display['show_on'],10) & SHOW_ON_ARCHIVES; $show_on['search'] = intval($display['show_on'],10) & SHOW_ON_SEARCH; $show_on['home'] = intval($display['show_on'],10) & SHOW_ON_HOME; $show_on['error'] = intval($display['show_on'],10) & SHOW_ON_ERROR; $show_on['static_page'] = intval($display['show_on'],10) & SHOW_ON_SFP; $posts_page = $static_front_page = "disabled='disabled'"; if((get_option('show_on_front')) == 'page' ) { $static_front_page = ''; } $html = "
" . "
".__('Show navigation group on', 'navt_domain')."...
"; return($html); } /** * Returns help information for items * * @param string $id - selector id * @return string json */ function item_help($id, $isIE) { navt_write_debug(NAVT_AJX, sprintf("%s::%s id %s, isIE: %s\n", __CLASS__, __FUNCTION__, $id, $isIE)); $subjects = array( TYPE_CAT => 'category-item', TYPE_PAGE => 'page-item', TYPE_AUTHOR => 'author-item', TYPE_ELINK => 'elink-item', TYPE_SEP => 'divider-item', 'homepage' => 'home-item', 'signin' => 'signin-item' ); $item = NAVTAJX::get_item($id); if( $item[TYP] == TYPE_LINK && $item[IDN] == HOMEIDN ) { $typ = 'homepage'; } elseif( $item[TYP] == TYPE_LINK && $item[IDN] == LOGINIDN ) { $typ = 'signin'; } else { $typ = $item[TYP]; } return( NAVTAJX::help($subjects[$typ], 0, $isIE) ); } /** * Returns the configuration options for an item based on its type * * @param string $id * @return string (json) * @since .96 */ function get_item_options($id) { navt_write_debug(NAVT_AJX, sprintf("%s::%s id %s\n", __CLASS__, __FUNCTION__, $id)); global $navt_blank, $checkit, $selected; $text = __('item not found', 'navt_domain'); $rc = NAVTAJX::mk_json_str(array('rc' => 'error', 'type' => 'not_found', 'msg' => $text)); $configured_ids = NAVTAJX::get_configured_items(); $item = $configured_ids[$id]; navt_write_debug(NAVT_AJX, sprintf("%s::%s item %s configuration:\n", __CLASS__, __FUNCTION__, $id), $item); if(is_array($item)) { $opts = intval($item[OPT],10) & 0xffff; $is_stan = (($opts & (TEXT_OVER_GRAPHIC+TEXT_WITH_SIDE_GRAPHIC+GRAPHIC_LINK)) ? '': $selected); $is_tog = (($opts & TEXT_OVER_GRAPHIC) ? $selected: ''); $is_twsg = (($opts & TEXT_WITH_SIDE_GRAPHIC) ? $selected: ''); $is_gl = (($opts & GRAPHIC_LINK) ? $selected: ''); $is_home = (TYPE_LINK == $item[TYP] && HOMEIDN == $item[IDN]) ? 1: 0; $is_author = ((TYPE_AUTHOR == $item[TYP]) ? 1: 0); $is_private = (($opts & ISPRIVATE) ? $checkit:''); $add_nofollow = (($opts & NOFOLLOW) ? $checkit:''); // common stuff $ttl = (( TYPE_ELINK == $item[TYP] ) ? __('User defined URI', 'navt_domain') : $item[TTL]); $html = "
" . "

$ttl

" . "
" . "

" . __('Menu item alias', 'navt_domain').":

" . ""; if( !$is_author ) { $html .= "

" . __('Anchor type', 'navt_domain') . ":


" . "

" . __('CSS class for graphic', 'navt_domain').":

" . ""; } if( $item[TYP] == TYPE_PAGE ) { // nothing special here } elseif($item[TYP] == TYPE_CAT) { $show_in_list = (($opts & SHOW_IN_LIST) ? $checkit:''); $append_post_count = (($opts & APPEND_POST_COUNT) ? $checkit:''); $show_if_empty = (($opts & SHOW_IF_EMPTY) ? $checkit:''); $use_desc_as_tip = (($opts & USE_CAT_DESC) ? $checkit:''); $html .= " " . "

". __('show in WP category list', 'navt_domain')."


" . " " . "

" . __('append post count', 'navt_domain')."


" . " " . "

".__('show if empty', 'navt_domain'). "


" . " " . "

".__('use description as tooltip') . "

"; } elseif($item[TYP] == TYPE_AUTHOR) { $show_avatar = (($opts & SHOW_AVATAR) ? $checkit:''); $use_default_avatar = (($opts & USE_DEF_AVATAR) ? $checkit:''); $append_post_count = (($opts & APPEND_AUTHOR_POST_COUNT) ? $checkit:''); $show_author_if_empty = (($opts & SHOW_AUTHOR_IF_EMPTY) ? $checkit:''); $inc_website = (($opts & INC_WEBSITE) ? $checkit:''); $inc_bio = (($opts & INC_BIO) ? $checkit:''); $inc_email = (($opts & INC_EMAIL) ? $checkit:''); $hide_link_text = (($opts & NO_LINK_TEXT) ? $checkit:''); $def_av = NAVT::get_url() . '/' . IMG_AVATAR; $av = ((isBlank($item[EX2]) ? $def_av: $item[EX2])); $av_list = NAVT::build_avatar_list(1, 0, null, $av); $html .= "
" . " " . "

".__('show avatar', 'navt_domain')."


" . " " . "

" . __('use default avatar', 'navt_domain')."


" . "

" . __('Avatar list', 'navt_domain') . ":

". "" . "

" . __('User avatar URI', 'navt_domain').":

" . "
" . " " . "

" . __('show if no posts', 'navt_domain')."


" . " " . "

" . __('append author post count', 'navt_domain')."


" . " " . "

" . __('include web site', 'navt_domain')."


" . " " . "

" . __('include user bio', 'navt_domain')."


" . " " . "

" . __('include user email', 'navt_domain')."


" . " " . ""; } elseif($item[TYP] == TYPE_ELINK) { $open_in_same_win = (($opts & OPEN_SAMEWIN) ? $checkit:''); $v = $item[TTL]; // uri $html .= "

" . __('URI', 'navt_domain') . ":

" . "
" . " " . "

".__('open in same window', 'navt_domain')."

"; } elseif($item[TYP] == TYPE_LINK) { if( $item[IDN] == LOGINIDN ) { $create_login_form = (($opts & USE_FORM) ? $checkit:''); $use_referral_direct = (($opts & REDIRECT_REFER) ? $checkit:''); $use_url_redirect = (($opts & REDIRECT_URL) ? $checkit:''); $v = $item[EX2]; $html .= "" . " " . "

" . __('create sign-in form', 'navt_domain')."


" . " " . "

" . __('use referral page redirect', 'navt_domain')."


" . " " . "

" . __('use URL redirect', 'navt_domain')."


" . "

" . __('redirect URL', 'navt_domain').":

" . ""; } elseif( $item[IDN] == HOMEIDN ) { $html .= ""; } } elseif($item[TYP] == TYPE_SEP) { $is_plain_text = (($opts & PLAIN_TEXT_OPTION) ? $selected:''); $is_hrule = (($opts & HRULE_OPTION) ? $selected:''); $is_empty_space = ((isBlank($is_plain_text) && isBlank($is_hrule)) ? $selected : ''); if( !isBlank($is_hrule) ) { $item[NME] = __('horizontal rule', 'navt_domain'); } elseif( !isBlank($is_empty_space) ) { $item[NME] = __('empty space', 'navt_domain'); } $dv_list = "" . "" . ""; $html .= "

" . __('Divider type', 'navt_domain') . ":

" . ""; } if(!$is_home) { $html .= "
" . "

" . __('set to private', 'navt_domain') . "

"; } if($item[TYP] != TYPE_SEP) { $html .= "
". "

".__('add', 'navt_domain')." rel='nofollow' ". "

" .
            __(

" . "

" .
            __(

". "

" . "
". "

" .
            __(

"; // substitutions $html = str_replace('@ID@', $id, $html); $html = str_replace('@ALIAS@', wp_specialchars($item[NME]), $html); $html = str_replace('@URI@', $item[EX2], $html); $html = str_replace('@USERCLASS@', $item[EXT], $html); $html = str_replace('@SRC@', $navt_blank, $html); $rc = NAVTAJX::mk_json_str(array('rc' => 'ok', 'html' => $html)); } navt_write_debug(NAVT_AJX, sprintf("%s::%s rc=%s\n", __CLASS__, __FUNCTION__, $rc)); return($rc); } /** * Returns the level option for an item * * @param string $id * @return string (json) * @since .96 */ function set_item_level($id, $direction) { navt_write_debug(NAVT_AJX, sprintf("%s::%s id %s, direction %s\n", __CLASS__, __FUNCTION__, $id, $direction)); global $icfg; $text = __('item not found', 'navt_domain'); $rc = NAVTAJX::mk_json_str(array('rc' => 'error', 'type' => 'not_found', 'msg' => $text)); $configured_ids = NAVTAJX::get_configured_items(); $item = $configured_ids[$id]; if( is_array($item) ) { $level = intval($item[LVL],10); $clevel = 'level-'.$level; if( $direction == 'up' ) { $level = (($level + 1 > 5 ) ? 0: $level + 1); } else { $level = (($level - 1 < 0) ? 5: $level - 1); } $nlevel = 'level-'.$level; $item[LVL] = $level; NAVTAJX::update_item($id, $item); $rc = NAVTAJX::mk_json_str(array('rc' => 'ok', 'id' => $id, 'cl' => $clevel, 'nl' => $nlevel)); } return($rc); } /** * Connects or disconnects an item from the menu * * @param string $id * @param boolean $setting * @return string (json) * @since .96 */ function set_item_disc($id) { navt_write_debug(NAVT_AJX, sprintf("%s::%s id %s \n", __CLASS__, __FUNCTION__, $id)); global $icfg; $setting = 0; $text = __('item not found', 'navt_domain'); $rc = NAVTAJX::mk_json_str(array('rc' => 'error', 'id' => $id, 'type' => 'not_found', 'msg' => $text)); $configured_ids = NAVTAJX::get_configured_items(); $item = $configured_ids[$id]; $alias = $item[NME]; $group = $item[GRP]; $force_disc = 0; if( is_array($item) ) { $opts = intval($item[OPT],10); if( TYPE_PAGE == $item[TYP] ) { $force_disc = (($opts & ISDRAFTPAGE) ? 1: 0); } if( $opts & DISCONNECTED ) { $opts -= DISCONNECTED; } else { $opts += DISCONNECTED; $setting = 1; } if( $force_disc ) { if( !($opts & DISCONNECTED) ) { $opts += DISCONNECTED; $setting = 1; } } $rc = NAVTAJX::mk_json_str(array('rc' => 'ok', 'id' => $id, 'disc' => $setting, 'group' => $group, 'alias' => $alias)); $item[OPT] = $opts; NAVTAJX::update_item($id, $item); } return($rc); } /** * Set item options * * @param string $id * @param array $options * @return string (json) * @since .96 */ function set_item_options($id, $options) { navt_write_debug(NAVT_AJX, sprintf("%s::%s id %s, options: \n", __CLASS__, __FUNCTION__, $id), $options); global $icfg; $configured_ids = NAVTAJX::get_configured_items(); $item = $configured_ids[$id]; $group = $item[GRP]; $private = $opt = 0; if( is_array($item) ) { $alias = $item[NME]; $anchorclass = $avatar_path = $uri_path = $url_redirect = ''; foreach($options as $option => $value) { navt_write_debug(NAVT_AJX, sprintf("%s::%s option: %s, value: %s \n", __CLASS__, __FUNCTION__, $option, $value)); switch( $option ) { case 'alias': { $alias = NAVT::clean_item_alias($value); if(isBlank($alias)) { $errmsg = __('invalid alias name', 'navt_domain'); $errclass = '-aliasbox'; } break; } case 'anchorclass': { $anchorclass = strip_tags($value); $anchorclass = stripslashes($anchorclass); break; } case 'avatar_path': { $avatar_path = strip_tags($value); $avatar_path = stripslashes($avatar_path); break; } case 'uri_path': { $uri_path = strip_tags($value); $uri_path = stripslashes($uri_path); break; } case 'selected_avatar': { $default_avatar = $value; break; } case 'anchortype': { $opt |= (intval($value,10) & 0xffff); break; } case 'nofollow': { $opt |= NOFOLLOW; break; } case 'private' : { $opt |= ISPRIVATE; $private = 1; break; } case 'show_in_wp_cat_list': { $opt |= SHOW_IN_LIST; break; } case 'append_author_post_count': { $opt |= APPEND_AUTHOR_POST_COUNT; break; } case 'append_cat_post_count': { $opt |= APPEND_POST_COUNT; break; } case 'show_author_if_empty': { $opt |= SHOW_AUTHOR_IF_EMPTY; break; } case 'show_cat_if_empty': { $opt |= SHOW_IF_EMPTY; break; } case 'use_cat_desc': { $opt |= USE_CAT_DESC; break; } case 'show_avatar': { $opt |= SHOW_AVATAR; break; } case 'use_default_avatar': { $opt |= USE_DEF_AVATAR; break; } case 'inc_website': { $opt |= INC_WEBSITE; break; } case 'inc_bio': { $opt |= INC_BIO; break; } case 'inc_email': { $opt |= INC_EMAIL; break; } case 'hide_link_text': { $opt |= NO_LINK_TEXT; break; } case 'open_in_same_window': { $opt |= OPEN_SAMEWIN; break; } case 'use_referral_redirect': { $opt |= REDIRECT_REFER; break; } case 'use_url_redirect': { $opt |= REDIRECT_URL; break; } case 'create_login_form': { $opt |= USE_FORM; break; } case 'selected_divider' : { $opt |= (intval($value,10) & 0xffff); if( $opt & HRULE_OPTION ) { $alias = __('horizontal rule', 'navt_domain'); } elseif( !($opt & PLAIN_TEXT_OPTION) ) { $alias = __('empty space', 'navt_domain'); } break; } case 'url_redirect': { $url_redirect = strip_tags($value); $url_redirect = stripslashes($url_redirect); break; } default: { break; } } if( isset($errmsg) ) { // option error occurred $rc = NAVTAJX::mk_json_str(array('rc' => 'error', 'msg' => $errmsg, 'suffix' => $errclass)); break; } }// end for if( !isset($rc) ) { if( TYPE_AUTHOR == $item[TYP] ) { if($opt & SHOW_AVATAR) { if( !($opt & USE_DEF_AVATAR) ) { if(isBlank($avatar_path) ) { // avatar is missing $t = __('avatar is missing', 'navt_domain'); $rc = NAVTAJX::mk_json_str(array('rc' => 'error', 'msg' => $t, 'suffix' => '-avbox')); } else { $item[EX2] = $avatar_path; } } else { $item[EX2] = $default_avatar; } } else { $item[EX2] = ''; } } else if( TYPE_ELINK == $item[TYP] ) { if(isBlank($uri_path) ) { // uri is missing $t = __('URI is missing', 'navt_domain'); $rc = NAVTAJX::mk_json_str(array('rc' => 'error', 'msg' => $t, 'suffix' => '-uribox')); } else { $item[TTL] = $uri_path; } } else if( TYPE_LINK == $item[TYP] ) { if( LOGINIDN == $item[IDN] ) { if( $opt & REDIRECT_URL ) { if(isBlank($url_redirect) ) { // uri is missing $t = __('URL is missing', 'navt_domain'); $rc = NAVTAJX::mk_json_str(array('rc' => 'error', 'msg' => $t, 'suffix' => '-url-redirect')); } else { $item[EX2] = $url_redirect; } } else { $item[EX2] = ''; } } } } if( TYPE_AUTHOR != $item[TYP] ) { if( $opt & (TEXT_WITH_SIDE_GRAPHIC | TEXT_OVER_GRAPHIC | GRAPHIC_LINK ) ) { if(isBlank($anchorclass) ) { $t = __('CSS class is missing', 'navt_domain'); $rc = NAVTAJX::mk_json_str(array('rc' => 'error', 'msg' => $t, 'suffix' => '-anchor-class')); } else { $item[EXT] = $anchorclass; } } else { $item[EXT] = ''; } } if( !isset($rc) ) { $item[NME] = $alias; $item[OPT] = $opt; $level = intval($item[LVL],10); NAVTAJX::update_item($id, $item); $rc = NAVTAJX::mk_json_str(array('rc' => 'ok', 'alias' => $alias, 'group' => $group, 'isprivate' => $private, 'level' => $level)); } } else { // item not found $t = __('item not found', 'navt_domain'); $rc = NAVTAJX::mk_json_str(array('rc' => 'error', 'type' => 'not_found', 'msg' => $t)); } return($rc); } /** * Verify that item option settings are not missing * * @param string $id * @return json string * @since .96 * @internal not implemented */ function verify_item_options($id) { navt_write_debug(NAVT_AJX, sprintf("%s::%s id %s: \n",__CLASS__, __FUNCTION__, $id)); $is_valid = 1; $configured_ids = NAVTAJX::get_configured_items(); $item = $configured_ids[$id]; if( !is_array($item) ) { // probably a new item $item_id = split('-', $id); $item[TYP] = $item_id[1]; $item[IDN] = $item_id[2]; $item[OPT] = 0; $item[EXT] = $item[EX2] = ''; if( TYPE_AUTHOR == $item[TYP] ) { $item[OPT] |= (SHOW_AVATAR | USE_DEF_AVATAR); } if( TYPE_ELINK == $item[TYP] ) { $item[TTL] = 'http://'; } } $opt = intval($item[OPT],10) & 0xffff; if( $opt & TEXT_WITH_SIDE_GRAPHIC ) { if( isBlank($item[EXT]) ) { navt_write_debug(NAVT_AJX, sprintf("%s::%s id %s twsg [anchor missing]\n",__CLASS__, __FUNCTION__, $id)); // missing anchor class $is_valid = 0; } } if( TYPE_AUTHOR == $item[TYP] ) { if($opt & SHOW_AVATAR) { if( !($opt & USE_DEF_AVATAR) ) { if( isBlank($item[EXT]) ) { navt_write_debug(NAVT_AJX, sprintf("%s::%s id %s [user avatar missing]\n",__CLASS__, __FUNCTION__, $id)); // avatar is missing $is_valid = 0; } } } } else if( TYPE_ELINK == $item[TYP] ) { if( isBlank($item[TTL]) ) { navt_write_debug(NAVT_AJX, sprintf("%s::%s id %s [user uri missing]\n",__CLASS__, __FUNCTION__, $id)); // uri is missing $is_valid = 0; } } else if( TYPE_LINK == $item[TYP] ) { if( LOGINIDN == $item[IDN] ) { if( $opt & REDIRECT_URL ) { if( isBlank($item[EX2]) ) { navt_write_debug(NAVT_AJX, sprintf("%s::%s id %s [user redirect missing]\n",__CLASS__, __FUNCTION__, $id)); // uri is missing $is_valid = 0; } } } } $rc = NAVTAJX::mk_json_str(array('rc' => 'ok', 'verify' => $is_valid)); return($rc); } /** * Returns a prompt to remove an item * * @param string $id * @return string (json) * @since .96 */ function ask_remove_item($id) { navt_write_debug(NAVT_AJX, sprintf("%s::%s id %s\n",__CLASS__, __FUNCTION__, $id)); global $navt_blank; $alias = $group = ''; $item = NAVTAJX::get_item($id); if( !empty($item) ) { $alias = $item[NME]; $group = $item[GRP]; } $title = 'Delete This Item?'; $html = "

".__("Select Ok to remove '$alias' from the group.", 'navt_domain')."

". "
". "

".__('Ok', 'navt_domain')."

". "

".__('Cancel', 'navt_domain')."

". "
"; // substitutions $html = str_replace('@ID@', $id, $html); $rc = NAVTAJX::mk_json_str(array('rc' => 'ok', 'html' => $html, 'title' => $title, 'width' => 400, 'height' => 140, 'group' => $group, 'alias' => $alias, 'id' => $id )); return($rc); } /** * Update item settings * * @param string $id * @param array $item * @since .96 */ function update_item($id, $item) { navt_write_debug(NAVT_AJX, sprintf("%s::%s id %s, item: \n",__CLASS__, __FUNCTION__, $id), $item); global $icfg; $group = $item[GRP]; $icfg[$group][$id] = $item; NAVT::update_option(ICONFIG, $icfg); return; } /** * returns an array of all configured items * Each key is an item selector id * * @return array * @since .96 */ function get_configured_items() { global $icfg; $all_ids = array(); $groups = $icfg; if( is_array($groups) ) { foreach( $groups as $group => $members ) { foreach( $members as $id => $data ) { $all_ids[$id] = $data; } } } //navt_write_debug(NAVT_AJX, sprintf("%s::%s all ids\n",__CLASS__, __FUNCTION__), $all_ids); return( $all_ids ); } /** * remove configured group * * @param string $target_group * @return array - new copy of the configuration * @since .96 */ function remove_configured_group($target_group) { navt_write_debug(NAVT_AJX, sprintf("%s::%s group %s\n",__CLASS__, __FUNCTION__, $target_group)); global $icfg, $gcfg; $n_icfg = array(); $target_group = strtolower($target_group); if(is_array($icfg)) { foreach( $icfg as $group => $members ) { if($target_group != $group ) { $n_icfg[$group] = $members; } } $n_gcfg = array(); foreach( $gcfg as $key => $group_data ) { if( $key != $target_group ) { $n_gcfg[$key] = $group_data; } } $gcfg = $n_gcfg; if( count($n_icfg) > 0 ) { NAVT::update_option(ICONFIG, $n_icfg); NAVT::update_option(GCONFIG, $n_gcfg); $icfg = $n_icfg; $gcfg = $n_gcfg; } return; } } /** * Insert a item into a group * * @param string $target_group * @param string $target_id * @param array $item * @return array - new copy of the configuration * @since .96 */ function insert_configured_item($target_group, $target_id, $item) { navt_write_debug(NAVT_AJX, sprintf("%s::%s group %s, id %s, item:\n", __CLASS__, __FUNCTION__, $target_group, $target_id), $item); global $icfg; $item[GRP] = $target_group; $ngroups = array(); $groups = $icfg; $target_group = strtolower($target_group); if(is_array($groups)) { foreach( $groups as $group => $members ) { if($target_group != $group ) { $ngroups[$group] = $members; continue; } else { foreach( $members as $id => $member ) { $ngroups[$group][$id] = $groups[$group][$id]; } // add the new item to the bottom of this group $ngroups[$target_group][$target_id] = $item; } } } return( $ngroups ); } /** * remove an item from a group * * @param string $target_group * @param string $target_id * @return array - new copy of the configuration * @since .96 */ function remove_configured_item($target_group, $target_id) { navt_write_debug(NAVT_AJX, sprintf("%s::%s group %s, id %s\n", __CLASS__, __FUNCTION__, $target_group, $target_id)); global $icfg; $ngroups = array(); $groups = $icfg; $target_group = strtolower($target_group); if(is_array($groups)) { foreach( $groups as $group => $members ) { if($target_group == $group ) { $ngroups[$group] = $members; continue; } else { foreach( $members as $id => $member ) { if( $target_id != $id ) { $ngroups[$group][$id] = $groups[$group][$id]; } } } } } return( $ngroups ); } /** * Check for the existance of a group name * * @param string $name * @return boolean (1 = name exists) * @since .96 */ function check_for_duplicate_group($name) { global $gcfg; $name = strtolower($name); return( (array_key_exists($name, $gcfg) ? 1: 0 ) ); } /** * Returns a specific item * * @param string $id */ function get_item( $id ) { $configured_ids = NAVTAJX::get_configured_items(); $item = $configured_ids[$id]; return($item); } /** * Creates a json message from an array of keys/values * * @param array $msg_protocol * @return string * @since .96 */ function mk_json_str($msg_protocol) { $msg = '{'; foreach( $msg_protocol as $key => $value ) { $msg .= sprintf('"%s":"%s",', $key, $value); } $msg = preg_replace('/,$/', '}', $msg); //navt_write_debug(NAVT_AJX, sprintf("%s::%s msg = %s\n",__CLASS__, __FUNCTION__, $msg)); return($msg); } }// end class