Ejemplo n.º 1
0
 public function LoadMenu($params)
 {
     $oMenu = new MenuCollectionContainer();
     $locale = isset($params[self::LOCALE]) ? $params[self::LOCALE] : null;
     $szSQL = self::SELECT_FROM_JOIN(array(self::tblFldsAll(), ResDetailModel::tblFldsAll(), ResValLngStrModel::tblFld(ResValLngStrModel::VALUE) . " as " . self::LONG_STR_NAME, ResValShrtStrModel::tblFld(ResValShrtStrModel::VALUE) . " as " . self::SHORT_STR_NAME, ResValObjectModel::tblFld(ResValObjectModel::VALUE) . " as " . self::OBJ_NAME, ResValBigIntModel::tblFld(ResValBigIntModel::VALUE) . " as " . self::BIG_INT_NAME, ImageModel::tblFld(ImageModel::IMG_PATH), ResValIntModel::tblFld(ResValIntModel::VALUE) . " as " . self::SHORT_INT_NAME, ResTypeModel::TYPE, ResTypeModel::TYPE_NAME, MenuClassMapModel::tblFld(MenuClassMapModel::CLASS_NAME), MenuClassMapModel::tblFld(MenuClassMapModel::METHOD_NAME), MenuClassMapModel::tblFld(MenuClassMapModel::PARAMS)), array(self::tbl(), MenuResModel::leftJoin(array(array(self::tblFld(self::MENU_ID), MenuResModel::tblFld(MenuResModel::MENU_ID)))), ResDetailModel::leftJoin(array(array(MenuResModel::tblFld(MenuResModel::RES_ID), ResDetailModel::tblFld(ResDetailModel::RES_ID))), array(isset($locale) ? ResDetailModel::tblFld(ResDetailModel::LOCALE) : null)), ResTypeModel::leftJoin(array(array(ResDetailModel::tblFld(ResDetailModel::TYPE_ID), ResTypeModel::tblFld(ResTypeModel::TYPE_ID)))), ResValLngStrModel::leftJoin(array(array(MenuResModel::tblFld(MenuResModel::RES_ID), ResValLngStrModel::tblFld(ResValLngStrModel::RES_ID)))), ResValShrtStrModel::leftJoin(array(array(MenuResModel::tblFld(MenuResModel::RES_ID), ResValShrtStrModel::tblFld(ResValShrtStrModel::RES_ID)))), ResValObjectModel::leftJoin(array(array(MenuResModel::tblFld(MenuResModel::RES_ID), ResValObjectModel::tblFld(ResValObjectModel::RES_ID)))), ResValBigIntModel::leftJoin(array(array(MenuResModel::tblFld(MenuResModel::RES_ID), ResValBigIntModel::tblFld(ResValBigIntModel::RES_ID)))), ImageModel::leftJoin(array(array(ResValBigIntModel::tblFld(ResValBigIntModel::VALUE), ImageModel::tblFld(ImageModel::IMG_ID))), array(array(ResTypeModel::tblFld(ResTypeModel::TYPE), "='" . \Av\Component\Menu\iMenuModelInterface::TYPE_IMAGE . "'"))), ResValIntModel::leftJoin(array(array(MenuResModel::tblFld(MenuResModel::RES_ID), ResValIntModel::tblFld(ResValIntModel::RES_ID)))), MenuClassMapModel::leftJoin(array(array(self::tblFld(self::MENU_ID), MenuClassMapModel::tblFld(MenuClassMapModel::MENU_ID))))), null, array(self::tblFld(self::POS_X), self::tblFld(self::POS_Y)));
     $arrSQL = array();
     if (isset($locale)) {
         $arrSQL[] = $locale;
     }
     $cDB =& $this->GetDBAdapter();
     $rs = $cDB->Execute($szSQL, $arrSQL);
     //        $this->AddDebugAsObject($rs->sql, __METHOD__ . " SQL: line #" . __LINE__);
     if (!empty($error)) {
         //            $this->AddDebugAsObject($szSQL, __METHOD__ . " failed SQL: line #" . __LINE__);
         //            $this->AddDebugAsObject($arrSQL, __METHOD__ . " failed SQL params are: line #" . __LINE__);
         //            $this->AddDebugAsObject($error, __METHOD__ . " SQL error:  line #" . __LINE__);
         return false;
     }
     while ($this->isValid($rs)) {
         $oMenu->AddToCollection($rs->fields[self::TAG], $rs->fields[self::POS_X], $rs->fields[self::POS_Y], $rs->fields);
         $rs->MoveNext();
     }
     //        echo __METHOD__ . " #" .__LINE__ . " menus : <br><pre>" . print_r($oMenu, true) . "</pre><br>";
     return $oMenu;
 }
Ejemplo n.º 2
0
 /**
  * Replace single MenuContainer object or array. Replace range of menus if MenuCollectionContainer
  * @param string $tag
  * @param int $x  - initial X of left-top conner where start replacement
  * @param int $y  - initial Y of left-top conner where start replacement
  * @param \Av\Component\Menu\MenuContainer|\Av\Component\Menu\MenuCollectionContainer|array $Menu
  */
 public function ReplaceInCollection($tag, $x, $y, $Menu)
 {
     if ($Menu instanceof \Av\Component\Menu\MenuContainer) {
         $this->_menu_collection[$tag][$x][$y] = $Menu;
     } elseif ($Menu instanceof \Av\Component\Menu\MenuCollectionContainer) {
         $y_original = $y;
         foreach ($Menu->GetCollection() as $menu_x_y) {
             foreach ($menu_x_y as $menu_y) {
                 $y = $y_original;
                 foreach ($menu_y as $menu) {
                     $this->_menu_collection[$tag][$x][$y] = $Menu;
                     $y++;
                 }
             }
             $x++;
         }
     } elseif (is_array($Menu)) {
         $this->_menu_collection[$tag][$x][$y] = new MenuContainer($Menu);
     }
 }