Beispiel #1
0
    /**
     * Get All Groups
     * Static function
     *
     * @return array(string)
     * @access public
     */
    static function getAllGroups($returnStack = false, $reset = false)
    {
        static $rowGroups;
        if (!isset($rowGroups) || $reset) {
            $rowGroups = array();
            $sql = '
				select distinct
					groupsStack_row
				from
					mod_standard_rows
			';
            $q = new CMS_query($sql);
            while ($data = $q->getArray()) {
                $groupStackString = $data["groupsStack_row"];
                $groupStack = new CMS_stack();
                $groupStack->setTextDefinition($groupStackString);
                foreach ($groupStack->getElements() as $group) {
                    if (!SensitiveIO::isInSet($group[0], $rowGroups) && $group[0]) {
                        $rowGroups[] = $group[0];
                    }
                }
            }
        }
        //sort groups
        natcasesort($rowGroups);
        if ($returnStack) {
            $stack = new CMS_stack();
            $stack->setValuesByAtom(1);
            foreach ($rowGroups as $rowGroup) {
                $stack->add($rowGroup);
            }
            return $stack;
        } else {
            return $rowGroups;
        }
    }
Beispiel #2
0
 /**
  * Add two Clearances stacks together
  *
  * @param  CMS_stack $pageClearances page clearances to add to this profile
  * @return void
  * @access public
  */
 protected function _addStackClearances($stack1, $stack2)
 {
     if (!is_a($stack1, "CMS_stack")) {
         $this->raiseError('Stack1 must be a valid stack object : ' . $stack1);
         return false;
     }
     if (!is_a($stack2, "CMS_stack")) {
         $this->raiseError('Stack2 must be a valid stack object : ' . $stack2);
         return false;
     }
     if ($stack1->getValuesByAtom() == 2 && $stack2->getValuesByAtom() == 2) {
         //create arrays from clearances stacks (easier to manage)
         $stack1Clearance = array();
         foreach ($stack1->getElements() as $clearanre) {
             $stack1Clearance[$clearanre[0]] = $clearanre[1];
         }
         $stack2Clearance = array();
         foreach ($stack2->getElements() as $clearanre) {
             $stack2Clearance[$clearanre[0]] = $clearanre[1];
         }
         //then add both together
         $newClearance = array();
         foreach ($stack1Clearance as $clearance => $clearanceValue) {
             if (isset($newClearance[$clearance]) && $newClearance[$clearance] < $clearanceValue || !isset($newClearance[$clearance])) {
                 $newClearance[$clearance] = $clearanceValue;
             }
         }
         foreach ($stack2Clearance as $clearance => $clearanceValue) {
             if (isset($newClearance[$clearance]) && $newClearance[$clearance] < $clearanceValue || !isset($newClearance[$clearance])) {
                 $newClearance[$clearance] = $clearanceValue;
             }
         }
         //set CMS_stack with new pages clearance
         $addedClearances = new CMS_stack();
         foreach ($newClearance as $clearance => $clearanceValue) {
             $addedClearances->add($clearance, $clearanceValue);
         }
         return $addedClearances;
     } elseif ($stack1->getValuesByAtom() == 1 && $stack2->getValuesByAtom() == 1) {
         //create arrays from clearances stacks (easier to manage)
         $stack1Clearance = array();
         foreach ($stack1->getElements() as $clearanre) {
             $stack1Clearance[$clearanre[0]] = $clearanre[0];
         }
         $stack2Clearance = array();
         foreach ($stack2->getElements() as $clearanre) {
             $stack2Clearance[$clearanre[0]] = $clearanre[0];
         }
         //then add both together
         $newClearance = array_unique(array_merge($stack1Clearance, $stack2Clearance));
         //set CMS_stack with new pages clearance
         $addedClearances = new CMS_stack();
         $addedClearances->setValuesByAtom(1);
         // Assume 1 atom
         foreach ($newClearance as $clearance) {
             $addedClearances->add($clearance);
         }
         return $addedClearances;
     } else {
         $this->raiseError('Can\'t add stack objects without the same value by atom number ...');
         return false;
     }
 }
    /**
     * Get All Groups
     * Static function
     *
     * @return array(string)
     * @access public
     */
    static function getAllGroups($returnStack = false)
    {
        static $templateGroups;
        if (!isset($templateGroups)) {
            $templateGroups = array();
            $sql = '
				select distinct
					groupsStack_pt
				from
					pageTemplates
				where 
					private_pt=0
			';
            $q = new CMS_query($sql);
            while ($data = $q->getArray()) {
                $groupStackString = $data["groupsStack_pt"];
                $groupStack = new CMS_stack();
                $groupStack->setTextDefinition($groupStackString);
                foreach ($groupStack->getElements() as $group) {
                    if (!SensitiveIO::isInSet($group[0], $templateGroups) && $group[0]) {
                        $templateGroups[] = $group[0];
                    }
                }
            }
        }
        //sort groups
        natcasesort($templateGroups);
        if ($returnStack) {
            $stack = new CMS_stack();
            $stack->setValuesByAtom(1);
            foreach ($templateGroups as $tplGroup) {
                $stack->add($tplGroup);
            }
            return $stack;
        } else {
            return $templateGroups;
        }
    }