Reverse-finds one file or directory with a given name/subpath

@param string  $name
@param boolean $reload
@param boolean $reversed
@param string  $type
763022
public function findReversed($name, $reload = false, $type = 'all')
	{
		return $this->find($name, $reload, true, $type);
	}
780518
private function findFile($name, $ext)
	{
		if (null === $ext)
			$ext = $this->default_ext;
		$basename = basename($name);
		$type = $this->getTypeForExt($ext);

		if (isset(self::$files[$this->prefix][$type][$name])
		 && file_exists($file = self::$files[$this->prefix][$type][$name]))
			return $file;

		foreach ($this->paths as $path)
		{
			$prefixes = isset($path['prefixes']) ? $path['prefixes'] : array();
			$prefix = isset($prefixes[$type]) ? $prefixes[$type] . '/' : '';

			foreach ($path['directories'] as $directory)
			{
				$files = glob(rtrim($directory, '/') . '/' . $prefix . $name . '.*');
				if (!$files) // no file found
					continue;

				foreach ($files as $file)
				{
					list($found_name, $found_ext) = $this->getNameAndExtension($file);
					
					if ($basename != basename($found_name) || $ext != $found_ext)
						continue;

					self::$files[$this->prefix][$ext][$name] = $file;
					self::$file_added = true;

					return self::$files[$this->prefix][$ext][$name];
				}
			}
		}

		return null;
	}
597655
public static function IsRemovable($Type, $Name) {
      
      switch ($Type) {
         case self::TYPE_APPLICATION:
            $ApplicationManager = Gdn::Factory('ApplicationManager');
            
            if ($IsRemovable = !array_key_exists($Name, $ApplicationManager->EnabledApplications())) {
               $ApplicationInfo   = ArrayValue($Name, $ApplicationManager->AvailableApplications(), array());
               $ApplicationFolder = ArrayValue('Folder', $ApplicationInfo, '');
               
               $IsRemovable = IsWritable(PATH_APPLICATIONS . DS . $ApplicationFolder);
            }
         break;
         case self::TYPE_PLUGIN:
            if ($IsRemovable = !array_key_exists($Name, Gdn::PluginManager()->EnabledPlugins())) {
               $PluginInfo   = ArrayValue($Name, Gdn::PluginManager()->AvailablePlugins(), FALSE);
               $PluginFolder = ArrayValue('Folder', $PluginInfo, FALSE);
               
               $IsRemovable = IsWritable(PATH_PLUGINS . DS . $PluginFolder);
            }
         break;
         case self::TYPE_THEME:
            // TODO
            $IsRemovable = FALSE;
         break;
      }
      
      return $IsRemovable;
   }
998070
public function begin($name, $type = 'replace')
    {
        $stacks = [$name, $type];
        if (!isset($this->opens[$name])) {
            $stacks[] = $this->placeholder($name);
        } elseif ($this->opens[$name]) {
            throw new BlockException($name, 'is opened');
        }

        $this->opens[$name] = true;
        $this->stacks[] = $stacks;
        ob_start();
    }
1058967
public function reload($name, $group = true)
	{
		if ($group === true)
		{
			$group = pathinfo($name, PATHINFO_FILENAME);
		}

		$this->delete($group);

		return $this->load($name, $group);
	}
503980
public static function retrieveReversal($id, $reversalId, $params = null, $opts = null)
    {
        return self::_retrieveNestedResource($id, static::PATH_REVERSALS, $reversalId, $params, $opts);
    }
961476
protected static function _current($name, $type)
	{
		// -v or --version
		if (\Cli::option('v', \Cli::option('version', '')) !== '')
		{
			\Cli::write('You can not define a version when using the "current" command.', 'red');
		}

		$migrations = \Migrate::current($name, $type);

		if ($migrations)
		{
			\Cli::write('Newly installed migrations for '.$type.':'.$name.':', 'green');
			foreach ($migrations as $migration)
			{
				\Cli::write('- '.$migration);
			}
		}
		else
		{
			// migration is already on current version
			\Cli::write('Already on the current migration version for '.$type.':'.$name.'.');
		}
	}
1331608
private function composeFilename($name, $type)
    {
        if (empty($name))
        {
            $name = 'default';
        }
        $folder = Eresus_Kernel::app()->getFsRoot() . '/templates/';
        if ($type)
        {
            $folder .= $type . '/';
        }
        $filename = $folder . $name . '.html';
        if (!file_exists($filename) && 'default' != $name)
        {
            $filename = $folder . 'default.html';
        }
        return $filename;
    }
913699
public function path($name, $folder = false)
    {

        // the current namespace prefix
        $prefix = $name;

        // work backwards through the namespace names of the fully-qualified
        // class name to find a mapped file name
        while (false !== $pos = strrpos($prefix, '\\')) {

            // retain the trailing namespace separator in the prefix
            $prefix = substr($name, 0, $pos + 1);

            // the rest is the relative class name
            $relative_class = substr($name, $pos + 1);

            // try to load a mapped file for the prefix and relative class
            $mapped_file = $this->loadMappedFile($prefix, $relative_class, $folder);
            if ($mapped_file) {
                return $mapped_file;
            }

            // remove the trailing namespace separator for the next iteration
            // of strrpos()
            $prefix = rtrim($prefix, '\\');
        }

        // never found a mapped file
        return false;
    }
707226
public function delete($name, $type = '')
    {
        $legacyKernel = Eresus_Kernel::app()->getLegacyKernel();
        $filename = $legacyKernel->froot . 'templates/';
        if ($type)
        {
            $filename .= "$type/";
        }
        $filename .= "$name.html";
        $result = filedelete($filename);
        return $result;
    }
290095
public function kcfinder($name, $type = 'file', array $attribs = array(), $kcfinderPath = null)
    {
        if (null !== $kcfinderPath) {
            self::$kcfinderPath = $kcfinderPath;
        }

        $src = self::$kcfinderPath . '?type=' . $type . '&amp;lang=' . $this->locale->getLanguage();

        if (isset($attribs['src'])) {
            unset($attribs['src']);
        }

        $xhtml  = '<div ' . $this->_htmlAttribs($attribs) . '>';
        $xhtml .= '<iframe id="' . $this->view->escape($name) . '" src="' . $src . '"></iframe>';
        $xhtml .= '</div>';

        return $xhtml;
    }
1272524
protected function load_if_needed($name)
  {
    // Reload when retrieving dirty data
    if ($this->_loaded && empty($this->_operations) && !empty($this->_dirty[$name]))
    {
      return $this->load();
    }

    // Lazy loading!
    else if ($this->_loaded === NULL && isset($this->_object['_id']) && !isset($this->_changed['_id']) && $name != '_id')
    {
      return $this->load();
    }
    return FALSE;
  }
113889
public function findAllFiles($name, $reload = false, $reversed = false)
	{
		return $this->findAll($name, $reload, $reversed, 'file');
	}
62896
public function loadFilter($type, $name)
    {
        $_plugin = "smarty_{$type}filter_{$name}";
        $_filter_name = $_plugin;
        if ($this->smarty->loadPlugin($_plugin)) {
            if (class_exists($_plugin, false)) {
                $_plugin = array($_plugin, 'execute');
            }
            if (is_callable($_plugin)) {
                $this->smarty->registered_filters[$type][$_filter_name] = $_plugin;
                return true;
            }
        }
        throw new SmartyException("{$type}filter \"{$name}\" not callable");
        return false;
    }
848376
public function make($type, $name)
    {
        if (!in_array(strtolower($type), $this->type)) {
            echo "{$type} must is {$this->stringSuport}";
            return false;
        }
        $data = $this->bindData($type, $name);
        $file = @fopen($name . '.php', 'w+');

        if ($file) {
            return fwrite($file, $data);
        } else {
            die("permission error!\n");
        }

    }
704808
public static function input($name, $type = INPUT_SERVER)
    {
        //====================================================================//
        // Standard Safe Reading
        $result = filter_input($type, $name);
        if (null !== $result) {
            return $result;
        }
        //====================================================================//
        // Fallback Reading
        if ((INPUT_SERVER === $type) && isset($_SERVER[$name])) {
            return $_SERVER[$name];
        }
        if ((INPUT_GET === $type) && isset($_GET[$name])) {
            return $_GET[$name];
        }

        return null;
    }
72096
public function child($name, $load = false)
    {
        if (!isset($this->_children[$name])){
            if ($load){
                $this->_children[$name] = Data::read($this->uri().'/'.$name);
            }else{
                return false;
            }
        }
        return $this->_children[$name];
    }