diff options
| author | Max Kremmel <xing@synapse.plus.com> | 2008-10-17 16:27:06 +0000 |
|---|---|---|
| committer | Max Kremmel <xing@synapse.plus.com> | 2008-10-17 16:27:06 +0000 |
| commit | 3d146c05309dd181172a4ec5683d623f0379b4f7 (patch) | |
| tree | 8354d155b72da4c62fe32ac73a38f19bc3d93e0e | |
| parent | 2fd4920e67dc946233468f3ba31c31d9f61af816 (diff) | |
| download | nexus-3d146c05309dd181172a4ec5683d623f0379b4f7.tar.gz nexus-3d146c05309dd181172a4ec5683d623f0379b4f7.tar.bz2 nexus-3d146c05309dd181172a4ec5683d623f0379b4f7.zip | |
various fixes to the way URLs are processed when they are entered into the formpre_update_permission
| -rw-r--r-- | Nexus.php | 24 | ||||
| -rw-r--r-- | menu_items.php | 3 | ||||
| -rw-r--r-- | templates/menu_items_details_inc.tpl | 4 | ||||
| -rw-r--r-- | templates/menu_items_edit_inc.tpl | 2 |
4 files changed, 18 insertions, 15 deletions
@@ -4,7 +4,7 @@ * * @abstract * @author xing <xing@synapse.plus.com> -* @version $Revision: 1.27 $ +* @version $Revision: 1.28 $ * @package nexus */ @@ -295,7 +295,7 @@ class Nexus extends NexusSystem { $bindVars = array( $pMenuId ); } $query .= ' ORDER BY nmi.`pos`'; - $result = $this->mDb->query( $query,array( $bindVars ) ); + $result = $this->mDb->query( $query, array( $bindVars ) ); while( !$result->EOF ) { $item = $result->fields; $item['display_url'] = $this->printUrl( $item ); @@ -331,9 +331,12 @@ class Nexus extends NexusSystem { if( isset( $pItemHash['rsrc'] ) && isset( $pItemHash['rsrc_type'] )) { switch( $pItemHash['rsrc_type'] ) { case 'external': - case 'internal': $ret .= $pItemHash['rsrc']; break; + case 'internal': + // annoying duplicate BIT_ROOT_URL removal and then adding is for people who add the leading section of the URL as well. + $ret .= str_replace( "//", "/", BIT_ROOT_URL. str_replace( BIT_ROOT_URL, "", $pItemHash['rsrc'] )); + break; case 'content_id': // create *one* object for each object *type* to call virtual methods. $row = $this->mDb->getRow( "SELECT `title`,`content_id`,`content_type_guid` FROM `".BIT_DB_PREFIX."liberty_content` WHERE `content_id`=?", array( $pItemHash['rsrc'] )); @@ -361,21 +364,20 @@ class Nexus extends NexusSystem { * @return fixed rsrc and corresponding rsrc_type */ function verifyRsrc( &$pParamHash ) { - $bit_root_pattern = "/^".preg_replace( "/\//", "\/", BIT_ROOT_URL )."/i"; + // if we have something like http:// or ftp:// in the url, we know it's external if( preg_match( "/^([a-zA-Z]{2,8}:\/\/)/i", $pParamHash['rsrc'] ) ) { $pParamHash['rsrc_type'] = 'external'; + } elseif( substr( $pParamHash['rsrc'], 0, 1 ) == '/' && substr( $pParamHash['rsrc'], 0, strlen( BIT_ROOT_URL )) != BIT_ROOT_URL ) { + // if the first character is a / and it doesn't match BIT_ROOT_URL, we know it's external even though it's in the same domain + $pParamHash['rsrc_type'] = 'external'; } elseif( is_numeric( $pParamHash['rsrc'] ) ) { + // if we have a numeric rsrc, we know it's either a content_id or a structure_id // if the resource type is numeric but we don't know what type it is, assume that it's a content_id - if( !isset( $pParamHash['rsrc_type'] ) ) { + if( empty( $pParamHash['rsrc_type'] ) ) { $pParamHash['rsrc_type'] = 'content_id'; } - } elseif( preg_match( $bit_root_pattern, $pParamHash['rsrc'] ) ) { - // if BIT_ROOT_URL can be found at the beginning of the string, assume it's an internal link - // in most cases this will only be a '/' but hopefully that's enough - $pParamHash['rsrc_type'] = 'internal'; } else { - // if we haven't caught this resource yet, we just prepend it with BIT_ROOT_URL and hope for the best - $pParamHash['rsrc'] = BIT_ROOT_URL.$pParamHash['rsrc']; + // any other URL will be considered as internal $pParamHash['rsrc_type'] = 'internal'; } } diff --git a/menu_items.php b/menu_items.php index 01a36de..12e47de 100644 --- a/menu_items.php +++ b/menu_items.php @@ -1,7 +1,7 @@ <?php /** * @author xing <xing@synapse.plus.com> - * @version $Revision: 1.9 $ + * @version $Revision: 1.10 $ * @package nexus * @subpackage functions */ @@ -85,6 +85,7 @@ $gBitSmarty->assign( 'perms', $perms ); // get a list of available resource types $rsrcTypes = array( + 'internal' => 'URL', 'external' => 'URL', 'content_id' => 'Content ID', 'structure_id' => 'Structure ID', diff --git a/templates/menu_items_details_inc.tpl b/templates/menu_items_details_inc.tpl index 1fdf913..7030caf 100644 --- a/templates/menu_items_details_inc.tpl +++ b/templates/menu_items_details_inc.tpl @@ -19,8 +19,8 @@ <small> {foreach from=$rsrcTypes key=key item=rsrc_type} {if $item.rsrc_type eq $key}{$rsrc_type}{/if} - {/foreach} - : {$item.rsrc|escape} + {/foreach}: {$item.rsrc|escape}<br /> + Final link: <a{if $item.rsrc_type == 'external'} class="external"{/if}{if $item.hint} title="{$item.hint}"{/if} href="{$item.display_url}">{$item.title}</a> {if $item.perm} • {tr}Permission{/tr}: {$item.perm}{/if} </small> </div> diff --git a/templates/menu_items_edit_inc.tpl b/templates/menu_items_edit_inc.tpl index 2d1e302..1bb5581 100644 --- a/templates/menu_items_edit_inc.tpl +++ b/templates/menu_items_edit_inc.tpl @@ -69,7 +69,7 @@ {formlabel label="Resource link" for="rsrc"} {forminput} <input type="text" name="rsrc" id="rsrc" size="50" value="{$editItem.rsrc|escape}" /> - {formhelp note="<dl><dt>External URL</dt><dd>enter full link. e.g.: <strong>http://www.example.com</strong></dd><dt>Internal URL</dt><dd>enter link beginning from your bitweaver installation directory. e.g.: <strong>wiki/rankings.php</strong></dd><dt>Content ID</dt><dd>enter the number referring to some content (e.g. the number assoctiated with each item in the content dropdown is a content ID). e.g.: <strong>3</strong></dd><dt>Structure ID</dt><dd>Enter the structure ID that you want to use.</dd></dl>"} + {formhelp note="<dl><dt>External URL</dt><dd>enter full link. e.g.: <strong>http://www.example.com/</strong></dd><dt>Internal URL</dt><dd>enter link beginning from your bitweaver installation directory. e.g.: <strong>wiki/rankings.php</strong></dd><dd>or the absolute URL. e.g.: <strong>/subpath/wiki/rankings.php</strong></dd><dt>Content ID</dt><dd>enter the number referring to some content (e.g. the number assoctiated with each item in the content dropdown is a content ID). e.g.: <strong>3</strong></dd><dt>Structure ID</dt><dd>Enter the structure ID that you want to use.</dd></dl>"} {/forminput} </div> |
