Example #1
0
 /**
  * Initializes the leaf
  * Passes the Parameters to its child leafs.
  *
  * @param int $index Index of this leaf
  * @param array $parentIndices Array with parent indices
  *
  * @return void
  */
 public function init($index, array $parentIndices = array())
 {
     if (!is_numeric($index) || !is_array($parentIndices)) {
         if (TYPO3_DLOG) {
             GeneralUtility::devLog('init (leaf) gets passed invalid parameters.', COMMERCE_EXTKEY, 3);
         }
         return;
     }
     // Store the index
     $this->view->setLeafIndex($index);
     $this->view->setParentIndices($parentIndices);
     // Add our own index to the parentIndices Array
     $parentIndices[] = $index;
     // Call 'init' for all child leafs - notice how the childleafs
     // are NOT read by mounts
     for ($i = 0; $i < $this->leafcount; ++$i) {
         // For every childleaf, set its parent leaf to the current leaf
         /**
          * Slave.
          *
          * @var \CommerceTeam\Commerce\Tree\Leaf\Slave $leafSlave
          */
         $leafSlave =& $this->leafs[$i];
         $leafSlave->setParentLeaf($this);
         $leafSlave->init($i, $parentIndices);
     }
 }
Example #2
0
 /**
  * Prints the single leaf item
  * Since this is a slave, this can only EVER be called by AJAX.
  *
  * @param int $startUid UID in which we start
  * @param int $bank Bank UID
  * @param int $pid UID of the parent item
  *
  * @return string HTML Code
  */
 public function printChildleafsByLoop($startUid, $bank, $pid)
 {
     // Check for valid parameters
     if (!is_numeric($startUid) || !is_numeric($bank)) {
         if (TYPO3_DLOG) {
             \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('printChildleafsByLoop (CommerceTeam\\Commerce\\Tree\\Leaf\\Slave) gets passed invalid parameters.', COMMERCE_EXTKEY, 3);
         }
         return '';
     }
     // Set the bank
     $this->view->setBank($bank);
     $this->data->setBank($bank);
     // Set the TreeName
     $this->view->setTreeName($this->treeName);
     // init vars
     $out = '';
     // get the Parent Item and set it as the starting child to print
     $child = $this->data->getChildByUid($startUid);
     $child['item_parent'] = $pid;
     // Abort if the starting Category is not found
     if (null == $child) {
         if (TYPO3_DLOG) {
             \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('printChildleafsByLoop (CommerceTeam\\Commerce\\Tree\\Leaf\\Slave)
                     cannot find the starting category by its uid.', COMMERCE_EXTKEY, 3);
         }
         return '';
     }
     /********************
      * Printing the Item
      *******************/
     // Give class 'expanded' if it is
     $exp = $this->data->isExpanded($child['uid']);
     $cssExpanded = $exp ? 'expanded' : '';
     // Add class 'last' if it is
     $isLast = $this->isLast($child, $pid);
     $cssLast = $isLast ? ' last' : '';
     $cssClass = $cssExpanded . ' ' . $cssLast;
     // start the element
     $out .= '<li class="' . $cssClass . '">
         <div>';
     // a slave can never be a bank
     $isBank = false;
     $hasChildren = $this->hasChildren($child);
     // pm icon
     $out .= $this->view->PMicon($child, $isLast, $exp, $isBank, $hasChildren);
     // icon
     $out .= $this->view->getIcon($child);
     // title
     $out .= $this->view->wrapTitle($child['title'], $child) . '</div>';
     /******************
      * Done printing
      *****************/
     // Print the children from the child leafs if the current leaf is expanded
     if ($exp) {
         $out .= '<ul>';
         for ($i = 0; $i < $this->leafcount; ++$i) {
             /**
              * Slave.
              *
              * @var \CommerceTeam\Commerce\Tree\Leaf\Slave $leaf
              */
             $leaf =& $this->leafs[$i];
             $out .= $leaf->printChildleafsByParent($child['uid'], $bank);
         }
         $out .= '</ul>';
     }
     // close the list item
     $out .= '</li>';
     return $out;
 }