Difference between revisions of "Ferreteria/v2/class/fcNavBase"

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
< Ferreteria‎ | v2‎ | class
Jump to navigation Jump to search
(Created page with "{{page/code/class}} * '''file''': {{l/ferreteria/file|menu/nav.php}} * '''extends''': {{l/version|class|fcPageElement}} * '''extender''': {{l/version|class|fcNavLink}} <source...")
 
 
Line 3: Line 3:
 
* '''extends''': {{l/version|class|fcPageElement}}
 
* '''extends''': {{l/version|class|fcPageElement}}
 
* '''extender''': {{l/version|class|fcNavLink}}
 
* '''extender''': {{l/version|class|fcNavLink}}
 +
* '''uses''': {{l/version|trait|ftExecutableTree}}
 
<source lang=php>
 
<source lang=php>
 
/*::::
 
/*::::

Latest revision as of 17:39, 19 January 2019

/*::::
  PURPOSE: base class for links and folders
  ADDS event-passing and consumption to PageElements
  ABSTRACT: n/i = Render(), new = RenderContent()
*/
abstract class fcNavBase extends fcPageElement {
    use ftExecutableTree;
    
    // ++ SETUP ++ //
    
    public function __construct($sText=NULL,$sPopup=NULL) {
	$this->SetLinkText($sText);
	$this->SetPopup($sPopup);
	$this->SetupDefaults();		// ALWAYS CALL THIS from constructor
    }

    // -- SETUP -- //
    // ++ EVENTS ++ //

    protected function SetupDefaults() {
	$this->SetVisible(TRUE);	// default
    }
    // DEFAULT: Do nothing; items are added from outside.
    protected function OnCreateElements(){}
    // DEFAULT: Nothing to do.
    protected function OnRunCalculations(){}

    // -- EVENTS -- //
    // ++ OUTPUT ++ //
    
    public function Render(){
	if ($this->GetShouldDisplay()) {
	    return $this->RenderFull();
	} else {
	    return NULL;
	}
    }
    /*----
      CEMENT
      PURPOSE: Renders everything that should show if the user has permission to use this node
    */
    protected function RenderFull() {
	return $this->RenderSelf();
    }
    protected function RenderSelf() {
	$sTag = get_class($this).'-'.$this->GetName();
	return "\n<li id='$sTag'>".$this->RenderContent()."</li>";
    }
    abstract protected function RenderContent();

    // -- OUTPUT -- //
    // ++ PROPERTY VALUES ++ //
    
    protected function SetLinkText($s) {
	$this->SetValue($s);
    }
    protected function GetLinkText() {
	return $this->GetValue();
    }
    private $isVisible;
    protected function SetVisible($b) {
	$this->isVisible = $b;
    }
    protected function GetVisible() {
	return $this->isVisible;
    }
    private $sPopup;
    protected function SetPopup($s) {
	$this->sPopup = $s;
    }
    protected function GetPopup() {
	return $this->sPopup;
    }
    
    // -- PROPERTY VALUES -- //
    // ++ PROPERTY CALCULATIONS ++ //
    
    protected function GetShouldDisplay() {
	return $this->GetVisible();
    }

    // -- PROPERTY CALCULATIONS -- //
}