Пример #1
0
 /**
  * Gets the Area object for the given page and area handle
  * @param Page|Collection $c
  * @param string $arHandle
  * @param int|null $arIsGlobal
  * @return Area
  */
 public static final function get(&$c, $arHandle)
 {
     if (!is_object($c)) {
         return false;
     }
     // Right now we are splitting the cache to deal with times when Areas
     // get converted to GlobalAreas and back the other way
     $globalCache = $arIsGlobal ? ':1' : '';
     $a = CacheLocal::getEntry('area', $c->getCollectionID() . ':' . $arHandle . $globalCache);
     if ($a instanceof Area) {
         return $a;
     }
     $db = Loader::db();
     // First, we verify that this is a legitimate area
     $v = array($c->getCollectionID(), $arHandle);
     $q = "select arID, arHandle, cID, arOverrideCollectionPermissions, arInheritPermissionsFromAreaOnCID, arIsGlobal, arParentID from Areas where cID = ? and arHandle = ?";
     $arRow = $db->getRow($q, $v);
     if ($arRow['arID'] > 0) {
         if ($arRow['arIsGlobal']) {
             $obj = new GlobalArea($arHandle);
         } else {
             if ($arRow['arParentID']) {
                 $arParentHandle = $db->GetOne('select arHandle from Areas where arID = ?', array($arRow['arParentID']));
                 $parent = Area::get($c, $arParentHandle);
                 $obj = new SubArea($arHandle, $parent);
             } else {
                 $obj = new Area($arHandle);
             }
         }
         $obj->setPropertiesFromArray($arRow);
         $obj->c = $c;
         return $obj;
     }
 }
Пример #2
0
 /**
  * Gets the Area object for the given page and area handle.
  *
  * @param Page $c
  * @param string $arHandle
  *
  * @return Area
  */
 public static final function get($c, $arHandle)
 {
     if (!is_object($c)) {
         return false;
     }
     $identifier = sprintf('/page/area/%s', $c->getCollectionID());
     $cache = \Core::make('cache/request');
     $item = $cache->getItem($identifier);
     if (!$item->isMiss()) {
         $areas = $item->get();
     } else {
         $areas = array();
         $db = Loader::db();
         // First, we verify that this is a legitimate area
         $v = array($c->getCollectionID());
         $q = 'select arID, arHandle, cID, arOverrideCollectionPermissions, arInheritPermissionsFromAreaOnCID, arIsGlobal, arParentID from Areas where cID = ?';
         $r = $db->Execute($q, $v);
         while ($arRow = $r->FetchRow()) {
             if ($arRow['arID'] > 0) {
                 if ($arRow['arIsGlobal']) {
                     $obj = new GlobalArea($arHandle);
                 } else {
                     if ($arRow['arParentID']) {
                         $arParentHandle = self::getAreaHandleFromID($arRow['arParentID']);
                         $obj = new SubArea($arHandle, $arParentHandle, $arRow['arParentID']);
                     } else {
                         $obj = new Area($arHandle);
                     }
                 }
                 $obj->setPropertiesFromArray($arRow);
                 $obj->c = $c;
                 $arRowHandle = $arRow['arHandle'];
                 $areas[$arRowHandle] = $obj;
             }
         }
         $item->set($areas);
     }
     return isset($areas[$arHandle]) ? $areas[$arHandle] : null;
 }
Пример #3
0
 public function setPropertiesFromArray($arr)
 {
     return parent::setPropertiesFromArray($arr);
 }