Exemple #1
0
/**
 * Returns the path components after /reason_package/
 * 
 * @param string full_path - absolute path
 * @param string suffix - extension to strip
 *
 * @return string
 */
function reason_basename($full_path, $suffix = '.php')
{
    // if the pathname does not appear to be in the reason include we do some symlink hocus pocus.
    if (carl_strpos($full_path, REASON_INC) === FALSE) {
        // first try local
        $local_path = reason_get_local_path("");
        $real_local_path = realpath($local_path);
        if (carl_substr($real_local_path, -1) != '/') {
            $real_local_path = $real_local_path . "/";
        }
        // add trailing slash.
        if (carl_strpos($full_path, $real_local_path) !== FALSE) {
            return carl_basename($local_path . carl_substr($full_path, carl_strlen($real_local_path)), $suffix, '/reason_package/');
        }
        // now try core
        $core_path = reason_get_core_path("");
        $real_core_path = realpath($core_path);
        if (carl_substr($real_core_path, -1) != '/') {
            $real_core_path = $real_core_path . "/";
        }
        // add trailing slash.
        if (carl_strpos($full_path, $real_core_path) !== FALSE) {
            return carl_basename($local_path . carl_substr($full_path, carl_strlen($real_core_path)), $suffix, '/reason_package/');
        }
    }
    return carl_basename($full_path, $suffix, '/reason_package/');
}
Exemple #2
0
 /**
  * Returns the path components after some directory in the path.
  *
  * @author Nathan White
  *
  * @param string full_path - absolute path
  * @param string suffix - extension to strip
  * @param string dir - some directory
  *
  * @return string
  */
 function carl_basename($full_path, $suffix, $dir)
 {
     $strlength = carl_strlen($dir);
     $strpos = carl_strpos($full_path, $dir);
     if (is_numeric($strpos)) {
         $partial_path = carl_substr($full_path, $strpos + $strlength);
         $filebasename = basename($partial_path, $suffix);
         $dirname = dirname($partial_path);
         return $dirname . '/' . $filebasename;
     } else {
         trigger_error('The directory ' . $dir . ' was not found in the full path string ' . $full_path . ' - returning just the file basename');
         return basename($full_path, $suffix);
     }
 }
 function leftbar_other()
 {
     $es = new entity_selector();
     $es->add_type(id_of('admin_link'));
     $es->add_right_relationship($this->site_id, relationship_id_of('site_to_admin_link'));
     $es->set_order('entity.name ASC');
     $links = $es->run_one();
     if ($links) {
         echo '<div class="typeNav"><strong>Other Links</strong>';
         echo '<ul class="leftList">';
         foreach ($links as $link) {
             $url = $link->get_value('relative_to_reason_http_base') == 'true' ? REASON_HTTP_BASE_PATH . $link->get_value('url') : $link->get_value('url');
             // lets add the current site_id if add_dynamic_site_id is set to true ... we do this in a very naive way.
             if ($link->has_value('add_dynamic_site_id') && $link->get_value('add_dynamic_site_id') == 'true') {
                 $pos = carl_strpos($url, '?');
                 if ($pos !== false) {
                     $base = $pos > 0 ? carl_substr($url, 0, $pos) : '';
                     $qs = carl_substr($url, $pos + 1);
                     $qs = str_replace('&amp;', '&', $qs);
                     parse_str($qs, $items);
                 } else {
                     $base = $url;
                 }
                 $items['site_id'] = $this->site_id;
                 $qs = http_build_query($items);
                 $url = $base . '?' . $qs;
             }
             echo '<li class="navItem"><a href="' . $url . '" class="nav">' . $link->get_value('name') . '</a></li>' . "\n";
         }
         echo '</ul></div>' . "\n";
     }
 }
 /**
  * Parses a module identifier string - returns an array.
  *
  * Note that no validation is done - the array could reference non existent classes, locations, or invalid params.
  */
 private static function parse_identifier($module_identifier)
 {
     $key_map = self::get_identifier_key_map();
     $cla_start = carl_strpos($module_identifier, $key_map['module_class']);
     $loc_start = carl_strpos($module_identifier, $key_map['module_location']);
     $par_start = carl_strpos($module_identifier, $key_map['module_params']);
     if ($cla_start !== false && $loc_start !== false && $par_start !== false) {
         $cla_len = carl_strlen($key_map['module_class']);
         $cla = carl_substr($module_identifier, $cla_start + $cla_len, $loc_start - $cla_start - $cla_len);
         $loc_len = carl_strlen($key_map['module_location']);
         $loc = carl_substr($module_identifier, $loc_start + $loc_len, $par_start - $loc_start - $loc_len);
         $par_len = carl_strlen($key_map['module_params']);
         $par = carl_substr($module_identifier, $par_start + $par_len, carl_strlen($module_identifier) - $par_start - $par_len);
         if (!empty($cla) && !empty($loc) && !empty($par)) {
             return array('module_class' => $cla, 'module_location' => $loc, 'module_params' => $par);
         }
     }
     return false;
 }