Futilities/v0.6/clade/Kiosk/WUIDL/@removed

From Woozle Writes Code
< Futilities‎ | v0.6‎ | clade‎ | Kiosk‎ | WUIDL
Jump to navigation Jump to search
Removed Code

2025-03-07

Outdated header from `ReadInput()`:

#
    /**
     * ACTION: match the input arguments up against the available (app) parameters, and turn them into an Action sequence
     * INSTAR: use cmdfmt as a template for interpreting the command arguments (I think this is a TODO)
     * SEQUENCE:
     *  * SetupOptions()
     *  * ParseInput() <- YOU ARE HERE <>
     *  * HandleInput() -- use the action sequence
     *  See also: BuildTerms()
     */

This is just the `HandleInput()` header comments, which are largely no longer applicable:

#
    /**
     * UNSTUB
     * ACTION: act on the input, as interpreted by ParseInput()
     *  Details: Iterate through the Action list, and do each one (Go()).
     * SEQUENCE:
     *  * SetupTerms() -- done earlier
     *  * ParseInput()
     *  * HandleInput() <- YOU ARE HERE <>
     *
     * xTHINKING: Maybe ParseInput() should create a sequence of action-objects, which we now iterate through?
     *  2024-12-27 update: this is in fact how it works now.
      HISTORY:
        2024-10-15 I started out thinking that I needed to iterate through CmdFmt to do stuff,
          but CmdFmt should have already been parsed into some more semantic form by ParseInput.
          * xTHINKING: We could either smash $argv[] into a string and then use CmdFmt as a
            template for that. or we could split CmdFmt into an array and compare elements
            one at a time. Tentatively. I'm going with the latter.
        2024-10-29 Okay, I think I finally have the concepts all worked out... I hope...
    */

2025-02-20

Commented out earlier:

#
    use Woozalia\Futil\Kiosk\WUIDL\aux\cTerms as TermsClass;

    // DEFAULT class to use for parsing CmdFmt string:
    protected function MatcherClass() : string { return MatcherClass::class; }
    // DEFAULT class for replacing matches found by Matcher:
    protected function LookupClass() : string { return LookupClass::class; }
    protected function TermsClass() : string { return TermsClass::class; }

2024-12-27

Commented out on 2024-12-17:

#
    // 2024-12-17 old version
    private $oMeta = NULL;  // object cache
    protected function TagFor_Item() : ItemTagIface {
        $oMeta = $this->oMeta;
        if (is_null($oMeta)) {
            $oTopTag = $this->MainTag();
            $osMeta = $oTopTag->QTagFor_Item();
            self::HardAssert($osMeta->HasIt(),'XML definition has no <item> section');  // TODO: maybe should be a coding-prompt
            $oMeta = $osMeta->GetIt();
            $this->oMeta = $oMeta;
        }
        return $oMeta;
    }

2024-12-19

Commented out on 2024-12-16:

#
    /**
     * ACTION: takes the UI config data which has already been imported into Singles and Plurals
     *  according to WUIDL tag-rules, and returns an array of just the recognized CLI options
     *  (but not how they're set; that's apparently another phase).
     * NOTE 2024-10-01 Although we *could* access the <meta> (now <item>) tags at this point, this is really
     *  just for reporting on the available *options*. Presumably whoever is calling AppOpts
     *  (t.k.a. OptsKnown()) will *also* report on the meta-tags (usage, docs URL...).
     * HISTORY:
     *  2024-11-16 It turns out this is returning the wrong type of object now...
     *    * actual: [WF]Sys\Data\Codec\Aux\XML\TagList\Array\cPlurals
     *    * needed: [WF]Sys\Data\iOptions
     */
    // 2024-12-16 old methodology
    protected function BuildTerms() : TermsIface {
        $oTop = $this->MainTag();

        $oVals = $oTop->TagFor_Request()->QValuesTag()->GetIt();

        return $oVals->OTags();
    }

2024-12-16

From `BuildOptions()`: probably mostly just debugging stuff, #-commented earlier, now removed

#
        self::GotToHere();
        $osCodec = $this->QCodec();
        $this->HardAssert($osCodec->HasIt(),'QCodec() has not been set.');
        $oCodec = $osCodec->GetIt();
        $oTop = $oCodec->QTag()->GetIt(); // This should be the WUIDL tag.
// STILL USED: $oTop = $this->MainTag();
        $oTags = $oTop->OTags();
        $oList = $oTags->OList();
        echo $oList->ReflectThis()->Report();
        echo $oList->ReflectThis()->Report();
        echo $oList->DumpAsTable();
        echo $oTop->ReflectThis()->Report();
        echo $oTop->RequestTag()->ReflectThis()->Report();
        echo $oTop->RequestTag()->DumpFull();
// STILL USED: $oVals = $oTop->RequestTag()->QValuesTag()->GetIt();
        echo $oVals->ReflectThis()->Report();
        echo $oVals->OTags()->ReflectThis()->Report();
        echo $oVals->OTags()->OList()->ReflectThis()->Report();
        echo $oVals->OTags()->OList()->DumpAsTable();
// STILL USED:
        return $oVals->OTags();  // 2024-11-17 If this works, then obviously the rest is redundant.

        #echo 'OTAG CLASS: '.get_class($oTrunk)."\n";
        #$osMetaTag = $oTop->QMetaTag();
        #echo $oTop->ReflectObject()->Report();
        $osValuesTag = $oTop->QTagFor_ReqValues();
        #self::GotToHere('Top-level tags found? Options:['.$osTagTerms->HasIt().'] Meta:['.$osTagMeta->HasIt().']');
        $this->HardAssert($osValuesTag->HasIt(),'XML config file has no <values> list inside <request>.');
        #$this->HardAssert($osTagMeta->HasIt(),'XML source has no <meta> list inside <wuidl>.');
        #echo 'CLASS for TagOpt: '.get_class($osTagOpt->GetIt())."\n";

        #$odClass = \Woozalia\Ferret\Sys\Narcissa\Class\Card\cBridge::FromObject($osTagOpt);
        #$odView = $odClass->View();
        #echo $odView->Render(); die();  // 2024-09-24 now working here (again)
        #echo $osTagOpt->ReflectObject()->Report();
        #echo $this->ReflectObject()->Report();
        $oValuesTag = $osValuesTag->GetIt();
        #$oTagMeta = $osTagMeta->GetIt();
        #echo $oTagTerms->OTags()->ReflectObject()->Report();
        #return $oValuesTag->OTags();

2024-12-04

This was commented out on 2024-11-17:

#
    // INSTAR: kicks the can over to the <wuidl> tag wrapper object
    // 2024-11-17 Nothing calls this anymore, and it can't work as written.
    public function RenderOptions() : string {
        $oScrn = Screen::Me();

        echo $this->ReflectThis()->Report(); die();

        $oaSing = $oOpts->OASingles();
        $oaPlur = $oOpts->OAPlurals();
        $nSing = $oaSing->Count();
        $nPlur = $oaPlur->Count();
        $arSing = $oaSing->GetVals();
        $arPlur = $oaPlur->GetVals();

        $oList = $oScrn->NewList();
        foreach ($arPlur as $sKey => $arTags) {
            $nTags = count($arTags);
            $oList->AddLine("[$sKey] element count: $nTags");
            $oListSub = $oList->NewList();
            #$sOut .= $oScrn->OpenList();
            foreach ($arTags as $sK2 => $oSub) {
                // list of options
                #$sOut .= $oScrn->ListItem("[$sK2] type: ".get_class($oSub));
                $oListSub->AddLine($oSub->RenderHelpLine());
            }
            #echo $oSub->ReflectObject()->Report();
            #$sOut .= $oScrn->ShutList();
        }
        #$sOut .= $oScrn->ShutList();
        #echo "SOUT:".CRLF.$sOut;
        $sOut = $oList->Render();
        return $sOut;
    }

2024-11-18

We're not doing the Singles/Plurals thing in the same object anymore, so this chunk from `RenderHelpText()` is now redundant (commented out earlier):

#
        // plurals

        $arTags = $oOpts->OAPlurals()->GetVals();
        $nTags = count($arTags);
        if ($nTags == 0) {
            $oListOuter->AddLine("WUIDL has no plurals.");
        } else {
            $oListOuter->AddLine("WUIDL plurals ($nTags):");
            $oListInner = $oListOuter->NewList();
            foreach ($arTags as $sKey => $arSub) {
                foreach ($arSub as $sKey2 => $oKiosk) {
                    // WORKING HERE 2024-11-08
                    $oListInner->AddLine($oKiosk->RenderHelpLine());
                }
            }
        }

2024-11-14

This no longer has any active code (commented out 2024-11-11). It was called from Setup().

#
    /**
     * ACTION: abstract the tag object data into something more semantic/usable
     *  (which can later be combined with the user input to produce an Action sequence)
     * SEQUENCE:
     *  * SetupOptions():
     *    * ParseSpecFile()
     *    * ParseOptions() <- YOU ARE HERE <>
     *  * ParseInput()
     *  * HandleInput() -- actually does stuff based on the interpreted meaning of the input arguments
     */
    protected function ParseOptions() {
        $oScrn = Screen::Me();

        // + OBJECTS
        self::GotToHere();

        $oRepl = $this->Matcher();  // object for finding replaceable expressions
        #echo 'MATCHER: '.$oRepl->ReflectObject()->Report();
        $oLook = $this->Lookup();   // object for replacing the expressions found
        #echo 'LOOKUP: '.$oLook->ReflectObject()->Report();

        // This is the WUIDL (outer/root) tag object:
        $oTagRoot = $this->MainTag();

        // 2024-11-03 Let's iterate through instead of expacting certain tags only...
        #echo $oTagRoot->ReflectObject()->Report();
        #$oTags = $oTagRoot->OTags();
        #$oaTags = $oTags->OList();
        #echo $oaTags->ReflectThis()->Report();
        #$oaTags->DumpAsTable();
        $oTagRoot->IndexOptions();
    }

From `ParseInput()`, after `$oaActs->AddIt($oAct)` (commented out 2024-10-20):

#
                    // TO DO: add ths Action to the list/script

                    // 2024-10-29 At *some* point we'll need the type info, won't we? Maybe when Action is processed.
                    // get the "type" attribute so we know what kind of option-action to make
                    $oAttrs = $oOpt->Attrs(); // KeyedArray
                    $osType = $oAttrs->GetItQ('type');
                    if ($osType->HasIt()) {
                        $sType = $osType->GetIt();
                        $sOptName = $oOpt->Name();
                        echo "ATTR TYPE=[$sType]".CRLF;
                        switch ($sType) {
                          case 'string':
                            break;
                          default:
                            echo self::CodingPrompt("Option [$sOptName] in UI def file has type '$sType', which is not recognized.");
                        }
                    } else {
                        echo self::CodingPrompt("Option [$sOptName] in UI def file does not have a type.");
                    }

2024-11-13

#
    // 2024-11-09 I *think* this is redundant now.
    protected function TermsTag() : TermsTagIface {
        $oTopTag = $this->MainTag();
        echo $oTopTag->ReflectThis()->Report();
        $osTagTerms = $oTopTag->QTermsTag();

        if (!$osTagTerms->HasIt()) {
            $oScrn = Screen::Me();
            // TODO: also give the filespec for the UI definition file.
            self::CodingPrompt('The '.$oScrn->XMLTagIt(MyTagIface::sTagName_TERMS).' tag was not found in the UI definition file.');
            die();
        }

        return $osTagTerms->GetIt();
    }

2024-11-11

Reworking how the tag-tree is indexed -- Singles and Plurals are no more:

#
    // NOTE 2024-11-10 The top-level WUIDL tags are all Singles.
    protected function ProcessSingleTags(ArrayIface $oa) {
        $oScrn = Screen::Me();

        $arTags = $oa->GetVals();
        $nTags = count($arTags);
        echo "SINGLE TAGS: $nTags".CRLF;
        if ($nTags == 0) {
            $this->HandleNoSingleTags();
            self::CodingPrompt('The WUIDL tag has no single-tags for some reason.');
        } else {
            $sS = ($nTags == 1) ? '' : 's';
            echo $nTags." tag$sS found:".CRLF;
            $oList = $oScrn->NewList();
            foreach ($arTags as $sKey => $oTag) {
                $oList->AddLine($oScrn->XMLTagIt($sKey) . ': ' . get_class($oTag));
                $this->ProcessTag($oTag);
            }
            echo $oList->Render();
        }
    }

...and some obsolete comments:

  • DETAILS:
    • MainTag() has the root (<wuidl>) tag object
    • MainTag()->QATag('terms')->GetIt() has the <options> tag object
    • MainTag()->QATag('terms')->GetIt()->OTags() is the outer options-list manager
    • MainTag()->QATag('terms')->GetIt()->OTags()->OAPlurals() is the list of plural-tags
  • ...each of which contains a list of the tags found

2024-11-10

from `protected function ParseOptions()`, 2024-11-10 (commented out earlier):

#
        $osTagTerms = $oTagRoot->QATag(MyTagIface::sTagName_TERMS);
        if (!$osTagTerms->HasIt()) {
            $oScrn = Screen::Me();
            // TODO: also give the filespec for the UI definition file.
            self::CodingPrompt('The '.$oScrn->XMLTagIt(MyTagIface::sTagName_TERMS).' tag was not found in the UI definition file.');
            die();
        }
        // This is the <options> tag object, which defines how the input is interpreted:
        $oTagTerms = $osTagTerms->GetIt();
        $oTagTerms2 = $oTagTerms->OTags();
        $oOptsPlur = $oTagTerms2->OAPlurals();
        #echo $oOptsPlur->ReflectObject()->Report();  // TODO: Need to get the plurals, which contains the <option> list.
        $arOpts = $oOptsPlur->GetIt(['option']);
        $arAllCues = [];
        foreach ($arOpts as $sKey => $oOpt) {
            // What we want to match against the CLI input is each Cue in the CueArray()
            $arOptCues = $oOpt->CueArray();
            echo "CUE [$sKey]: ".$oOpt->DumpLine().CRLF;
            foreach ($arOptCues as $ndx => $oCue) {
                #echo $oCue->ReflectObject()->Report(); die();
                $sCue = $oCue->Value();
                $arAllCues[$sCue] = $oOpt;  // 2024-10-27 LATER: may want to store the Cue object, but it will need to point to Option object somehow.
            }
            #echo "[$sKey]: ".$oOpt->DumpLine().CRLF;
            #echo $oOpt->ReflectObject()->Report(); die(CRLF);
        }
        #$oaCueOpts = ArrayClass::FromArray($arAllCues);
        $this->CueIndex()->SetAll($arAllCues);
        #$this->QCueIndex()->SetIt($oaCueOpts);