Registry PHP Class Code Examples

This page contains top rated real world PHP examples of class Registry extracted from open source projects. You can rate examples to help us improve the quality of examples

Example #1
Show file File: cbPluginHandler.php Project: bobozhangshao/HeartCare
0
 /**
  * loads a plugins params into memory
  *
  * @param null|int              $pluginId
  * @param null|Registry|string  $extraParams
  */
 public function _loadParams($pluginId, $extraParams = null)
 {
     if ($pluginId === null) {
         $pluginId = $this->getPluginId();
     } else {
         $pluginId = (int) $pluginId;
     }
     $plugin = $this->getCachedPluginObject($pluginId);
     if ($plugin === null) {
         return;
     }
     $paramsBase = $this->_getPluginParamsFromTable($plugin);
     if ($extraParams) {
         if (!$extraParams instanceof Registry) {
             /** @noinspection PhpDeprecationInspection */
             if ($extraParams instanceof cbParamsBase) {
                 /** @noinspection PhpDeprecationInspection */
                 $extraParams = new Registry($extraParams->toParamsArray());
             } else {
                 $extraParams = new Registry($extraParams);
             }
         }
         $extraArray = $extraParams->asArray();
         foreach ($extraArray as $k => $v) {
             $paramsBase->set($k, $v);
         }
     }
     $this->params = $paramsBase;
 }
Example #2
Show file File: newsfeed.php Project: adjaika/J3Base
0
 /**
  * Method to get newsfeed data.
  *
  * @param   integer  $pk  The id of the newsfeed.
  *
  * @return  mixed  Menu item data object on success, false on failure.
  *
  * @since   1.6
  */
 public function &getItem($pk = null)
 {
     $pk = !empty($pk) ? $pk : (int) $this->getState('newsfeed.id');
     if ($this->_item === null) {
         $this->_item = array();
     }
     if (!isset($this->_item[$pk])) {
         try {
             $db = $this->getDbo();
             $query = $db->getQuery(true)->select($this->getState('item.select', 'a.*'))->from('#__newsfeeds AS a');
             // Join on category table.
             $query->select('c.title AS category_title, c.alias AS category_alias, c.access AS category_access')->join('LEFT', '#__categories AS c on c.id = a.catid');
             // Join on user table.
             $query->select('u.name AS author')->join('LEFT', '#__users AS u on u.id = a.created_by');
             // Join over the categories to get parent category titles
             $query->select('parent.title as parent_title, parent.id as parent_id, parent.path as parent_route, parent.alias as parent_alias')->join('LEFT', '#__categories as parent ON parent.id = c.parent_id')->where('a.id = ' . (int) $pk);
             // Filter by start and end dates.
             $nullDate = $db->quote($db->getNullDate());
             $nowDate = $db->quote(JFactory::getDate()->toSql());
             // Filter by published state.
             $published = $this->getState('filter.published');
             $archived = $this->getState('filter.archived');
             if (is_numeric($published)) {
                 $query->where('(a.published = ' . (int) $published . ' OR a.published =' . (int) $archived . ')')->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')')->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')')->where('(c.published = ' . (int) $published . ' OR c.published =' . (int) $archived . ')');
             }
             $db->setQuery($query);
             $data = $db->loadObject();
             if (empty($data)) {
                 JError::raiseError(404, JText::_('COM_NEWSFEEDS_ERROR_FEED_NOT_FOUND'));
             }
             // Check for published state if filter set.
             if ((is_numeric($published) || is_numeric($archived)) && ($data->published != $published && $data->published != $archived)) {
                 JError::raiseError(404, JText::_('COM_NEWSFEEDS_ERROR_FEED_NOT_FOUND'));
             }
             // Convert parameter fields to objects.
             $registry = new Registry();
             $registry->loadString($data->params);
             $data->params = clone $this->getState('params');
             $data->params->merge($registry);
             $registry = new Registry();
             $registry->loadString($data->metadata);
             $data->metadata = $registry;
             // Compute access permissions.
             if ($access = $this->getState('filter.access')) {
                 // If the access filter has been set, we already know this user can view.
                 $data->params->set('access-view', true);
             } else {
                 // If no access filter is set, the layout takes some responsibility for display of limited information.
                 $user = JFactory::getUser();
                 $groups = $user->getAuthorisedViewLevels();
                 $data->params->set('access-view', in_array($data->access, $groups) && in_array($data->category_access, $groups));
             }
             $this->_item[$pk] = $data;
         } catch (Exception $e) {
             $this->setError($e);
             $this->_item[$pk] = false;
         }
     }
     return $this->_item[$pk];
 }
Example #3
Show file File: HandlingTest.php Project: franrtorres77/Net_RouterOS
0
 public function testTaglessModePassing()
 {
     $com1 = new Communicator(\HOSTNAME, PORT, true);
     Client::login($com1, USERNAME, PASSWORD);
     $reg1 = new Registry('dummy');
     $com2 = new Communicator(\HOSTNAME, PORT, true);
     $reg2 = new Registry('dummy');
     $this->assertNotEquals($reg1->getOwnershipTag(), $reg2->getOwnershipTag());
     $pingRequest1 = new Request('/ping address=' . HOSTNAME, null, 'ping');
     $pingRequest1->send($com1, $reg1);
     $response1_1 = new Response($com1, false, null, null, $reg1);
     $cancelRequest = new Request('/cancel');
     $reg1->setTaglessMode(true);
     $cancelRequest->setArgument('tag', $reg1->getOwnershipTag() . 'ping');
     $cancelRequest->send($com1, $reg1);
     $pingRequest2 = new Request('/ping count=2 address=' . HOSTNAME, null, 'ping');
     $pingRequest2->send($com2, $reg2);
     $response2_1 = new Response($com2, false, null, null, $reg2);
     $response2_2 = new Response($com2, false, null, null, $reg2);
     $response2_3 = new Response($com2, false, null, null, $reg2);
     $reg1->setTaglessMode(false);
     $com1->close();
     $com2->close();
     $this->assertEquals(Response::TYPE_DATA, $response2_1->getType());
     $this->assertEquals(Response::TYPE_DATA, $response2_2->getType());
     $this->assertEquals(Response::TYPE_FINAL, $response2_3->getType());
     $response1_2 = new Response($com1, false, null, null, $reg1);
     $response1_3 = new Response($com1, false, null, null, $reg1);
     $this->assertEquals(Response::TYPE_DATA, $response1_1->getType());
     $this->assertEquals(Response::TYPE_ERROR, $response1_2->getType());
     $this->assertEquals(Response::TYPE_FINAL, $response1_3->getType());
     $reg1->close();
     $this->assertStringStartsWith('-1_', $reg2->getOwnershipTag());
 }
Example #4
Show file File: newsfeed.php Project: educakanchay/kanchay
0
 /**
  * Method to get a single record.
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed  Object on success, false on failure.
  *
  * @since   1.6
  */
 public function getItem($pk = null)
 {
     if ($item = parent::getItem($pk)) {
         // Convert the params field to an array.
         $registry = new Registry();
         $registry->loadString($item->metadata);
         $item->metadata = $registry->toArray();
         // Convert the images field to an array.
         $registry = new Registry();
         $registry->loadString($item->images);
         $item->images = $registry->toArray();
     }
     // Load associated newsfeeds items
     $app = JFactory::getApplication();
     $assoc = JLanguageAssociations::isEnabled();
     if ($assoc) {
         $item->associations = array();
         if ($item->id != null) {
             $associations = JLanguageAssociations::getAssociations('com_newsfeeds', '#__newsfeeds', 'com_newsfeeds.item', $item->id);
             foreach ($associations as $tag => $association) {
                 $item->associations[$tag] = $association->id;
             }
         }
     }
     if (!empty($item->id)) {
         $item->tags = new JHelperTags();
         $item->tags->getTagIds($item->id, 'com_newsfeeds.newsfeed');
         $item->metadata['tags'] = $item->tags;
     }
     return $item;
 }
Example #5
Show file File: corecontent.php Project: grchis/Site-Auto
0
 /**
  * Overloaded bind function
  *
  * @param   array  $array   Named array
  * @param   mixed  $ignore  An optional array or space separated list of properties
  *                          to ignore while binding.
  *
  * @return  mixed  Null if operation was satisfactory, otherwise returns an error string
  *
  * @see     JTable::bind()
  * @since   3.1
  */
 public function bind($array, $ignore = '')
 {
     if (isset($array['core_params']) && is_array($array['core_params'])) {
         $registry = new Registry();
         $registry->loadArray($array['core_params']);
         $array['core_params'] = (string) $registry;
     }
     if (isset($array['core_metadata']) && is_array($array['core_metadata'])) {
         $registry = new Registry();
         $registry->loadArray($array['core_metadata']);
         $array['core_metadata'] = (string) $registry;
     }
     if (isset($array['core_images']) && is_array($array['core_images'])) {
         $registry = new Registry();
         $registry->loadArray($array['core_images']);
         $array['core_images'] = (string) $registry;
     }
     if (isset($array['core_urls']) && is_array($array['core_urls'])) {
         $registry = new Registry();
         $registry->loadArray($array['core_urls']);
         $array['core_urls'] = (string) $registry;
     }
     if (isset($array['core_body']) && is_array($array['core_body'])) {
         $registry = new Registry();
         $registry->loadArray($array['core_body']);
         $array['core_body'] = (string) $registry;
     }
     return parent::bind($array, $ignore);
 }
Example #6
Show file File: teams.php Project: esorone/efcpw
0
 /**
  * Method to get a set of records.
  *
  * @return	mixed	Objects on success, false on failure.
  */
 public function getItems()
 {
     if ($items = parent::getItems()) {
         $db = $this->getDbo();
         $query = $db->getQuery(true);
         // Include any manipulation of the data on the record e.g. expand out Registry fields
         // NB The params registry field - if used - is done automatcially in the JAdminModel parent class
         foreach ($items as $item) {
             $query->clear();
             // Convert the images field to an array.
             $registry = new Registry();
             $registry->loadString($item->images);
             $item->images = $registry->toArray();
             $registry = null;
             //release memory
             // Convert the urls field to an array.
             $registry = new Registry();
             $registry->loadString($item->urls);
             $item->urls = $registry->toArray();
             $registry = null;
             //release memory
         }
     }
     return $items;
 }
Example #7
Show file File: content.php Project: adjaika/J3Base
0
 /**
  * Overloaded bind function
  *
  * @param   array  $array   Named array
  * @param   mixed  $ignore  An optional array or space separated list of properties
  *                          to ignore while binding.
  *
  * @return  mixed  Null if operation was satisfactory, otherwise returns an error string
  *
  * @see     JTable::bind()
  * @since   11.1
  */
 public function bind($array, $ignore = '')
 {
     // Search for the {readmore} tag and split the text up accordingly.
     if (isset($array['articletext'])) {
         $pattern = '#<hr\\s+id=("|\')system-readmore("|\')\\s*\\/*>#i';
         $tagPos = preg_match($pattern, $array['articletext']);
         if ($tagPos == 0) {
             $this->introtext = $array['articletext'];
             $this->fulltext = '';
         } else {
             list($this->introtext, $this->fulltext) = preg_split($pattern, $array['articletext'], 2);
         }
     }
     if (isset($array['attribs']) && is_array($array['attribs'])) {
         $registry = new Registry();
         $registry->loadArray($array['attribs']);
         $array['attribs'] = (string) $registry;
     }
     if (isset($array['metadata']) && is_array($array['metadata'])) {
         $registry = new Registry();
         $registry->loadArray($array['metadata']);
         $array['metadata'] = (string) $registry;
     }
     // Bind the rules.
     if (isset($array['rules']) && is_array($array['rules'])) {
         $rules = new JAccessRules($array['rules']);
         $this->setRules($rules);
     }
     return parent::bind($array, $ignore);
 }
Example #8
Show file File: teamnaams.php Project: esorone/efcpw
0
 /**
  * Method to index an item. The item must be a FinderIndexerResult object.
  *
  * @param   FinderIndexerResult  $item    The item to index as an FinderIndexerResult object.
  * @param   string               $format  The item format
  *
  * @return  void
  *
  * @throws  Exception on database error.
  */
 protected function index(FinderIndexerResult $item, $format = 'html')
 {
     $item->setLanguage();
     // Check if the extension is enabled
     if (JComponentHelper::isEnabled($this->extension) == false) {
         return;
     }
     // Initialize the item parameters.
     $registry = new Registry();
     $registry->loadString($item->params);
     $item->params = JComponentHelper::getParams('com_knvbapi2', true);
     $item->params->merge($registry);
     $registry = null;
     //release memory
     $registry = new Registry();
     $registry->loadString($item->metadata);
     $item->metadata = $registry;
     $registry = null;
     //release memory
     // Trigger the onContentPrepare event.
     $item->summary = FinderIndexerHelper::prepareContent($item->summary, $item->params);
     $item->body = FinderIndexerHelper::prepareContent($item->body, $item->params);
     if ($this->sub_layout != 'default') {
         $view = $this->layout . '&layout=' . $this->sub_layout;
     } else {
         $view = $this->layout;
     }
     // Build the necessary route and path information.
     $item->url = $this->getURL($item->id, $this->extension, $view);
     $item->route = Knvbapi2HelperRoute::getTeamnaamRoute($item->slug, $item->catid, $item->language, $this->sub_layout);
     $item->path = FinderIndexerHelper::getContentPath($item->route);
     // Get the menu title if it exists.
     $title = $this->getItemMenuTitle($item->url);
     if (!empty($title) and $this->params->get('use_menu_title', true)) {
         $item->title = $title;
     } else {
         $item->title = $item->name;
     }
     // Add the meta-data processing instructions.
     $item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey');
     $item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc');
     $item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_name');
     // Translate the state.
     $item->state = $this->translateState($item->state);
     // Add the type taxonomy data.
     $item->addTaxonomy('Type', 'Teamnaam');
     // Add the created_by taxonomy data.
     if (!empty($item->created_by_alias)) {
         $item->addTaxonomy('Author', !empty($item->created_by_name) ? $item->created_by_name : $item->created_by);
     }
     // Add the category taxonomy data.
     $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access);
     // Add the language taxonomy data.
     $item->addTaxonomy('Language', $item->language);
     // Get content extras.
     FinderIndexerHelper::getContentExtras($item);
     // Index the item.
     $this->indexer->index($item);
 }