本文整理汇总了PHP中release_object函数的典型用法代码示例。如果您正苦于以下问题:PHP release_object函数的具体用法?PHP release_object怎么用?PHP release_object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了release_object函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: listAction
public function listAction()
{
$elementSetName = $this->_getParam('elset');
$elementName = $this->_getParam('elname');
$curPage = $this->_getParam('page');
$elementTextTable = $this->getDb()->getTable('ElementText');
$el = $this->getDb()->getTable('Element')->findByElementSetNameAndElementName($this->_unslugify($elementSetName), $this->_unslugify($elementName));
//$elTexts = $this->getDb()->getTable('ElementText')->findByElement($el->id);
$select = $elementTextTable->getSelect()->where('element_id = ?', $el->id)->order('text')->group('text');
$elTexts = $elementTextTable->fetchObjects($select);
//$sortedTexts = $elTexts->getSelect()->findByElement($el->id)->order('text');
$totalCategories = count($elTexts);
release_object($el);
// set-up pagination routine
$paginationUrl = $this->getRequest()->getBaseUrl() . '/categories/list/' . $elementSetName . '/' . $elementName . "/";
/*
$pageAdapter = new Zend_Paginator_Adapter_DbSelect($elementTextTable->getSelect()->where('element_id = ?', $el->id)->order('text')->group('text'));
*/
$paginator = Zend_Paginator::factory($select);
$paginator->setItemCountPerPage(20);
//$totalCategories = count($paginator);
$paginator->setCurrentPageNumber($curPage);
$this->view->paginator = $paginator;
//Serve up the pagination
// add other pagination items
$pagination = array('page' => $curPage, 'per_page' => 20, 'total_results' => $totalCategories, 'link' => $paginationUrl);
Zend_Registry::set('pagination', $pagination);
//$this->view->assign(array('texts'=>$elTexts, 'elset'=>$elementSetName, 'elname'=>$elementName, 'total_results'=>$totalCategories));
$this->view->assign(array('elset' => $elementSetName, 'elname' => $elementName, 'total_results' => $totalCategories));
}
示例2: emiglio_exhibit_builder_page_nav
function emiglio_exhibit_builder_page_nav($exhibitPage = null, $currentPageId)
{
if (!$exhibitPage) {
$exhibitPage = get_current_record('exhibit_page');
}
$parents = array();
$currentPage = get_record_by_id('Exhibit Page', $currentPageId);
while ($currentPage->parent_id) {
$currentPage = $currentPage->getParent();
array_unshift($parents, $currentPage->id);
}
$class = '';
$class .= $exhibitPage->id == $currentPageId ? 'current' : '';
$parent = array_search($exhibitPage->id, $parents) !== false ? ' parent' : '';
$html = '<li class="' . $class . $parent . '">' . '<a href="' . exhibit_builder_exhibit_uri(get_current_record('exhibit'), $exhibitPage) . '">' . metadata($exhibitPage, 'title') . '</a>';
$children = $exhibitPage->getChildPages();
if ($children) {
$html .= '<ul>';
foreach ($children as $child) {
$html .= emiglio_exhibit_builder_page_nav($child, $currentPageId);
release_object($child);
}
$html .= '</ul>';
}
$html .= '</li>';
return $html;
}
示例3: replaceDigitalObjectRelations
/**
* This is a filter function.
*
* If the relation text begins with thumb:, then the thumb: portion
* is stripped and the remaining urn is displayed as a thumbnail.
* If the relation text begins with full:, the full: portion
* is stripped and the remaining urn is displayed as a link.
*
* Any other relation text not meeting the criteria is simply returned as is.
*
* @param string - the text from the Relation field
* @return string - this will be an img tag if thumb:, a href tag if full:, or currently existing text.
*/
public function replaceDigitalObjectRelations($text, $args)
{
//If the relation has a full string, check to see if it has a thumb relation. If so, then
//display the thumb and link it out to the full image. Otherwise just make it a link.
if (preg_match(get_option('digitalobjectlinkerplugin_preg_full_image_string'), $text)) {
//Strip the full: from the text.
$fulllink = substr($text, strlen(get_option('digitalobjectlinkerplugin_full_image_tag')));
$fullid = $this->parseUniqueId($fulllink);
if ($fullid != 'no-id') {
$fulllink = trim(str_replace($fullid . ":", "", $fulllink));
}
//Create the link with parameters.
$fulllinkwithparams = $fulllink . "?buttons=Y";
//The only way that I could find to get all relations during the filter was to pull the relations from the database.
//Trying to pull from the metadata function seemed to throw this into an infinite loop.
//This first gets the element_id for the 'Relation' element from the 'Element' table (omeka_elements if you are looking in the db).
//Second, it then finds all of the 'Relation' element texts from the 'ElementText' table (omeka_element_texts) using
//the record ID which was passed in from the filter and the element_id that was retrieved.
$element = get_db()->getTable('Element')->findByElementSetNameAndElementName('Dublin Core', 'Relation');
$elementID = $element->id;
//Record ID that was passed in from the filter.
$recordID = $args['record']->id;
//We no longer need the element object that we retrieved so releas it.
release_object($element);
//Create the select for the ElementText table.
$select = get_db()->select()->from(array(get_db()->ElementText), array('text'))->where('record_id=' . $recordID . ' AND element_id = ' . $elementID);
//Fetch all of the relations. They come back as an array in this form:
//array(0 => array('text' => full:urn...), 1 => array('text' => thumb:urn....))
$relations = get_db()->getTable('ElementText')->fetchAll($select);
//Logger::log($relations);
//As long as at least one relation was returned, we can continue.
if (count($relations) > 0) {
foreach ($relations as $relation) {
//Make sure the relation is not the full relation that we are filtering. If it isn't,
//check to see if it is the thumb relation.
if ($relation['text'] != $text && preg_match(get_option('digitalobjectlinkerplugin_preg_thumb_string'), $relation['text'])) {
//Create a thumb image that links out to the full image.
$thumblink = substr($relation['text'], strlen(get_option('digitalobjectlinkerplugin_thumb_tag')));
if (!empty($thumblink)) {
$thumbid = $this->parseUniqueId($thumblink);
if ($thumbid != 'no-id') {
$thumblink = trim(str_replace($thumbid . ":", "", $thumblink));
}
if ($fullid == $thumbid) {
//Determine the width and height of the thumb.
$width = is_admin_theme() ? get_option('digitalobjectlinkerplugin_width_admin') : get_option('digitalobjectlinkerplugin_width_public');
return "<div class=\"item-relation\"><a href=\"" . $fulllinkwithparams . "\" target=\"_blank\"><img src=\"" . $thumblink . "\" alt=\"" . $thumblink . "\" height=\"" . $width . "\"></img></a></div>";
}
}
}
}
}
//If it reaches this point, the relations did not contain a thumbnail so return a plain link.
return "<a href=\"" . $fulllinkwithparams . "\" target=\"_blank\">" . $fulllink . "</a>";
} elseif (!preg_match(get_option('digitalobjectlinkerplugin_preg_thumb_string'), $text)) {
return $text;
}
return NULL;
}
示例4: makeNotPublic
public function makeNotPublic()
{
$this->public = false;
$item = $this->Item;
$item->public = false;
$item->save();
release_object($item);
}
示例5: _filterResultsByCollection
private function _filterResultsByCollection($results, $collection)
{
$collection_id = is_numeric($collection) ? $collection : $collection->id;
foreach ($results as $index => $result) {
if (!$result->appliesToCollection($collection_id)) {
unset($results[$index]);
release_object($result);
}
}
return $results;
}
示例6: getItems
public function getItems()
{
$iiTable = $this->getDb()->getTable('FeedImporter_ImportedItem');
$itemTable = $this->getDb()->getTable('Item');
$importedItems = $iiTable->findByImportId($this->id);
$items = array();
foreach ($importedItems as $importedItem) {
$items[] = $itemTable->find($importedItem->item_id);
release_object($importedItem);
}
return $items;
}
示例7: render
public function render(array $records)
{
$entries = array();
foreach ($records as $record) {
$entries[] = $this->itemToRss($record);
release_object($record);
}
$headers = $this->buildRSSHeaders();
$headers['entries'] = $entries;
$feed = Zend_Feed::importArray($headers, 'rss');
return $feed->saveXML();
}
示例8: coins
/**
* Return a COinS span tag for every passed item.
*
* @param array|Item An array of item records or one item record.
* @return string
*/
public function coins($items)
{
if (!is_array($items)) {
return $this->_getCoins($items);
}
$coins = '';
foreach ($items as $item) {
$coins .= $this->_getCoins($item);
release_object($item);
}
return $coins;
}
示例9: testCanInsertItem
public function testCanInsertItem()
{
$db = $this->db;
// Insert an item and verify with a second query.
$item = insert_item(array('public' => true), array('Dublin Core' => array('Title' => array(array('text' => 'foobar', 'html' => true)))));
$sql = "SELECT public FROM {$db->Item} WHERE id = {$item->id}";
$row = $db->fetchRow($sql);
$this->assertEquals(array('public' => 1), $row);
// Verify that element texts are inserted correctly into the database.
$sql = "SELECT COUNT(id) FROM {$db->ElementText} WHERE html = 1 AND " . "text = 'foobar' AND record_id = {$item->id}";
$this->assertEquals(1, $db->fetchOne($sql));
release_object($item);
}
示例10: addItem
public static function addItem(Omeka_Db $db)
{
// Keep the record objects from dying.
Zend_Registry::get('bootstrap')->getContainer()->db = $db;
$itemBuilder = new Builder_Item($db);
// Item should be public to avoid weird issues with ACL integration
// (test must authenticate a user in order to retrieve non-public
// items).
$itemBuilder->setRecordMetadata(array('public' => 1));
$itemBuilder->setElementTexts(array('Dublin Core' => array('Title' => array(array('text' => self::TEST_ITEM_TITLE, 'html' => 0)))));
$item = $itemBuilder->build();
release_object($item);
}
示例11: getCollectionNames
public function getCollectionNames()
{
$collectionTable = $this->getDb()->getTable('Collection');
$returnArray = array();
if (is_array(unserialize($this->collection_ids))) {
foreach (unserialize($this->collection_ids) as $collection_id) {
$collection = $collectionTable->find($collection_id);
$returnArray[] = $collection->name;
release_object($collection);
}
}
return $returnArray;
}
示例12: browseAction
public function browseAction()
{
//TODO: select by feed_id
if ($_POST) {
foreach ($_POST['tc'] as $tcId => $data) {
$record = $this->getTable()->find($tcId);
foreach ($data as $field => $value) {
switch ($field) {
case 'elements_map':
case 'tags_map':
$value = serialize($value);
break;
}
$record->{$field} = $value;
$record->save();
}
}
}
$page = $this->_getParam('page', 1);
$table = $this->getTable();
$feed_id = $this->_getParam('feed_id');
$fi_tags = $table->findBy(array('feed_id' => $feed_id), 10, $page);
$count = $table->fetchOne($table->getSelectForCount()->where('feed_id = ?', $feed_id));
/**
* Now process the pagination
*
**/
$paginationUrl = $this->getRequest()->getBaseUrl() . '/tags/browse/';
//Serve up the pagination
$pagination = array('page' => $page, 'per_page' => 10, 'total_results' => $count, 'link' => $paginationUrl);
Zend_Registry::set('pagination', $pagination);
$db = get_db();
$elSets = $db->getTable('ElementSet')->findAll();
//print_r($elSets);
$elSetPairs = array();
foreach ($elSets as $elSet) {
$elSetPairs[$elSet->id] = $elSet->name;
release_object($elSet);
}
$tagTable = $db->getTable('Tag');
$o_tags = $tagTable->findBy(array('sort' => 'alpha'));
$tagPairs = array();
foreach ($o_tags as $o_tag) {
$tagPairs[$o_tag->id] = $o_tag->name;
release_object($o_tag);
}
$priorityArray = range(1, 10);
$this->view->assign(array('tags' => $fi_tags, 'debug' => $pagination, 'elSetPairs' => $elSetPairs, 'tagPairs' => $tagPairs, 'priorityArray' => $priorityArray, 'feed_id' => $feed_id));
}
示例13: testDeleteItem
public function testDeleteItem()
{
$item = insert_item();
$record = new OaipmhHarvester_Record();
$record->item_id = $item->id;
$record->identifier = 'foo-bar';
$record->harvest_id = 10000;
$record->datestamp = '2011-07-11';
$record->save();
$item->delete();
$table = $this->db->getTable('OaipmhHarvester_Record');
release_object($item);
release_object($record);
$this->assertEquals(0, $table->count());
}
示例14: getElementSetAndElement
public function getElementSetAndElement()
{
$db = get_db();
$elTable = $db->getTable('Element');
$retObject = new StdClass();
$el_ids = unserialize($this->element_ids);
$retArray = array();
foreach ($el_ids as $el_id) {
$el = $elTable->find($el_id);
$elSet = $el->getElementSet();
$retArray[$elSet->name][] = $el->name;
release_object($el);
release_object($elSet);
}
return $retArray;
}
示例15: perform
public function perform()
{
$db = get_db();
//import the contributors to Guest Users
$sql = "SELECT * FROM {$db->ContributionContributors}";
$res = $db->query($sql);
$data = $res->fetchAll();
$contributorUserMap = array();
$validatorOptions = array('table' => $db->getTable('User')->getTableName(), 'field' => 'username', 'adapter' => $db->getAdapter());
$emailValidator = new Zend_Validate_EmailAddress();
foreach ($data as $contributor) {
//create username from email and set up for some validation checks
$username = $contributor['email'];
$email = $contributor['email'];
if ($user = $db->getTable('User')->findByEmail($contributor['email'])) {
$userContributorMap[$user->id][] = $contributor['id'];
} else {
if (!$emailValidator->isValid($email)) {
//can't save as a new user w/o valid unique email, so assign to superuser
_log("Email {$email} is invalid. Assigning to super user.", Zend_Log::INFO);
$user = $db->getTable('User')->find(1);
} else {
_log("Creating new guest user for email {$email}.");
$user = new User();
$name = trim($contributor['name']);
$user->username = $username;
$user->name = empty($name) ? "user" : $name;
$user->email = $email;
$user->role = "guest";
$user->active = false;
try {
$user->save();
} catch (Exception $e) {
_log($e->getMessage());
$user = $db->getTable('User')->find(1);
}
}
$userContributorMap[$user->id] = array($contributor['id']);
}
release_object($user);
}
$this->_mapUsersToItems($userContributorMap);
//we need to keep track of which contributors got mapped to which users
//so that the UserProfiles import of contributor info can match people up
$serialized = serialize($userContributorMap);
$putResult = file_put_contents(CONTRIBUTION_PLUGIN_DIR . '/upgrade_files/user_contributor_map.txt', $serialized);
}