本文整理汇总了PHP中JTableNested类的典型用法代码示例。如果您正苦于以下问题:PHP JTableNested类的具体用法?PHP JTableNested怎么用?PHP JTableNested使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JTableNested类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: check
/**
* Assert that the nested set data is valid.
*
* @return boolean True if the instance is sane and able to be stored in the database.
*
* @since 11.1
*/
public function check()
{
try {
parent::check();
} catch (\Exception $e) {
$this->setError($e->getMessage());
return false;
}
$this->parent_id = (int) $this->parent_id;
if (empty($this->rules)) {
$this->rules = '{}';
}
// JTableNested does not allow parent_id = 0, override this.
if ($this->parent_id > 0) {
// Get the JDatabaseQuery object
$query = $this->_db->getQuery(true)->select('COUNT(id)')->from($this->_db->quoteName($this->_tbl))->where($this->_db->quoteName('id') . ' = ' . $this->parent_id);
$this->_db->setQuery($query);
if ($this->_db->loadResult()) {
return true;
} else {
$this->setError('Invalid Parent ID');
return false;
}
}
return true;
}
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:33,代码来源:asset.php
示例2: mosCategory
function mosCategory(&$db)
{
///parent::__construct( $db );
// for 1.6
JTableNested::__construct('#__booklibrary_legacy_categories', 'id', $db);
$this->access = (int) JFactory::getConfig()->get('access');
// --
}
开发者ID:rdegennaro,项目名称:Check-It,代码行数:8,代码来源:category.php
示例3: __construct
public function __construct($table, $key = 'id', $alias = null, $db = null)
{
$this->_alias = $alias;
if (!isset($db)) {
$db = JFactory::getDbo();
}
parent::__construct($table, $key, $db);
}
开发者ID:Knuckle-ORM,项目名称:knorm,代码行数:8,代码来源:nestedbase.php
示例4: delete
/**
* Delete category record
*
* @author RickG
* @return boolean True on success
* @todo Add check for store and products assinged to category before allowing delete
*/
public function delete($pk = null, $children = true)
{
if (parent::delete($pk, $children)) {
return true;
} else {
return false;
}
}
开发者ID:srbsnkr,项目名称:sellingonlinemadesimple,代码行数:15,代码来源:xmlconfig.php
示例5: bind
/**
* Overloaded bind function
*
* @param array $hash named array
* @return mixed null is operation was satisfactory, otherwise returns an error
* @see JTable:bind
* @since 1.5
*/
public function bind($array, $ignore = '')
{
if (is_array($array['params'])) {
$registry = new JRegistry();
$registry->loadArray($array['params']);
$array['params'] = $registry->toString();
}
return parent::bind($array, $ignore);
}
开发者ID:joebushi,项目名称:joomla,代码行数:17,代码来源:menu.php
示例6: getTree
public function getTree($pk = null, $diagnostic = false)
{
$k = $this->_tbl_key;
$pk = is_null($pk) ? $this->{$k} : $pk;
if (!isset(self::$getTree[$pk][(int) $diagnostic])) {
self::$getTree[$pk][(int) $diagnostic] = parent::getTree($pk, $diagnostic);
}
return self::$getTree[$pk][(int) $diagnostic];
}
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:9,代码来源:address.php
示例7: store
public function store($updateNulls = false)
{
// Verify that the alias is unique
$table = JTable::getInstance('Category', 'Table', array('dbo' => $this->getDbo()));
if ($table->load(array('alias' => $this->alias, 'parent_id' => $this->parent_id)) && ($table->id != $this->id || $this->id == 0)) {
$this->setError(JText::_('JLIB_DATABASE_ERROR_CATEGORY_UNIQUE_ALIAS'));
return false;
}
return parent::store($updateNulls);
}
开发者ID:hixbotay,项目名称:executivetransport,代码行数:10,代码来源:category.php
示例8: delete
public function delete($pk = null, $children = true)
{
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_judirectory/tables');
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('id');
$query->from('#__judirectory_template_styles');
$query->where('template_id =' . $pk);
$db->setQuery($query);
$styleIds = $db->loadColumn();
if ($styleIds) {
$styleTable = JTable::getInstance("Style", "JUDirectoryTable");
foreach ($styleIds as $styleId) {
if (!$styleTable->delete($styleId)) {
return false;
}
}
}
return parent::delete($pk);
}
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:20,代码来源:template.php
示例9: store
/**
* Overloaded store function
*
* @param boolean $updateNulls True to update fields even if they are null.
*
* @return mixed False on failure, positive integer on success.
*
* @see JTable::store
* @since 11.1
*/
public function store($updateNulls = false)
{
$updated = parent::store($updateNulls);
// Verify that the alias is unique
$table = JTable::getInstance('Addon', 'oseMscTable');
$table->load($this->getRootId());
$table->rebuild($this->getRootId(), $table->lft, $table->level);
return $updated;
/*if($this->id != $this->getRootId())
{
$table->load($this->parent_id);
// Rebuild the paths of the category's children:
//oseExit($table);
if (!$table->rebuild($table->id, $table->lft, $table->level) && $updated) {
return false;
}
}
return $updated;*/
//$table->load($table->getRootId());
// Use new path for partial rebuild of table
// Rebuild will return positive integer on success, false on failure
//return ($table->rebuild());
//return ($this->rebuild($this->{$this->_tbl_key}, $this->lft, $this->level) > 0);
}
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:34,代码来源:addon.php
示例10: __construct
/**
* Constructor
*
* @param JDatabaseDriver $db Database driver object.
*
* @since 11.1
*/
public function __construct($db)
{
parent::__construct('#__assets', 'id', $db);
}
开发者ID:GitIPFire,项目名称:Homeworks,代码行数:11,代码来源:asset.php
示例11: hasPrimaryKey
/**
* Validate that the primary key has been set.
*
* @return boolean True if the primary key(s) have been set.
*
* @since 1.5.2
*/
public function hasPrimaryKey()
{
// For Joomla 3.2+ a native method has been provided
if (method_exists(get_parent_class(), 'hasPrimaryKey')) {
return parent::hasPrimaryKey();
}
// Otherwise, it checks if the only key field compatible for older Joomla versions is set or not
if (isset($this->_tbl_key) && !empty($this->_tbl_key) && empty($this->{$this->_tbl_key})) {
return false;
}
return true;
}
开发者ID:810,项目名称:redCORE,代码行数:19,代码来源:nested.php
示例12: store
/**
* Overloaded store function
*
* @param boolean $updateNulls True to update fields even if they are null.
*
* @return mixed False on failure, positive integer on success.
*
* @see JTable::store()
* @since 11.1
*/
public function store($updateNulls = false)
{
$db = JFactory::getDbo();
// Verify that the alias is unique
$table = JTable::getInstance('Menu', 'JTable', array('dbo' => $this->getDbo()));
if ($table->load(array('alias' => $this->alias, 'parent_id' => $this->parent_id, 'client_id' => (int) $this->client_id, 'language' => $this->language)) && ($table->id != $this->id || $this->id == 0)) {
if ($this->menutype == $table->menutype) {
$this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_UNIQUE_ALIAS'));
} else {
$this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_UNIQUE_ALIAS_ROOT'));
}
return false;
}
// Verify that the home page for this language is unique
if ($this->home == '1') {
$table = JTable::getInstance('Menu', 'JTable', array('dbo' => $this->getDbo()));
if ($table->load(array('home' => '1', 'language' => $this->language))) {
if ($table->checked_out && $table->checked_out != $this->checked_out) {
$this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_DEFAULT_CHECKIN_USER_MISMATCH'));
return false;
}
$table->home = 0;
$table->checked_out = 0;
$table->checked_out_time = $db->getNullDate();
$table->store();
}
// Verify that the home page for this menu is unique.
if ($table->load(array('home' => '1', 'menutype' => $this->menutype)) && ($table->id != $this->id || $this->id == 0)) {
$this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_HOME_NOT_UNIQUE_IN_MENU'));
return false;
}
}
if (!parent::store($updateNulls)) {
return false;
}
// Get the new path in case the node was moved
$pathNodes = $this->getPath();
$segments = array();
foreach ($pathNodes as $node) {
// Don't include root in path
if ($node->alias != 'root') {
$segments[] = $node->alias;
}
}
$newPath = trim(implode('/', $segments), ' /\\');
// Use new path for partial rebuild of table
// Rebuild will return positive integer on success, false on failure
return $this->rebuild($this->{$this->_tbl_key}, $this->lft, $this->level, $newPath) > 0;
}
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:59,代码来源:menu.php
示例13:
function __construct(&$db)
{
parent::__construct('ins_level', 'id', $db);
}
开发者ID:phucdnict,项目名称:cbcc_05062015,代码行数:4,代码来源:InsLevel.php
示例14: store
/**
* Method to store a node in the database table.
*
* @param boolean $updateNulls True to update null values as well.
*
* @return boolean True on success.
*/
public function store($updateNulls = false)
{
// Before store
if (!$this->beforeStore($updateNulls)) {
return false;
}
// Store
if (!parent::store($updateNulls)) {
return false;
}
// After store
if (!$this->afterStore($updateNulls)) {
return false;
}
return true;
}
开发者ID:prox91,项目名称:joomla-dev,代码行数:23,代码来源:nested.php
示例15: store
/**
* Overloaded store function
*
* @param boolean $updateNulls True to update null values as well.
* @return boolean True on success, false otherwise
* @since 1.5.7
*/
public function store($updateNulls = false)
{
if (!parent::store($updateNulls)) {
return false;
}
// If there aren't any sub categories there isn't anything to do anymore
$cats = JoomHelper::getAllSubCategories($this->cid, false, true, true, false);
if (!count($cats)) {
return true;
}
// Set state of all sub-categories
// according to the settings of this category
$query = $this->_db->getQuery(true)->update(_JOOM_TABLE_CATEGORIES)->set('published = ' . (int) $this->published)->where('cid IN (' . implode(',', $cats) . ')');
$this->_db->setQuery($query);
if (!$this->_db->query()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
// Set 'in_hidden' of all sub-categories
// according to hidden state of this category
// (but only if there was a change of this state)
if ($this->_hidden != $this->hidden && !$this->in_hidden || $this->_in_hidden != $this->in_hidden) {
if ($this->hidden == 0 && $this->in_hidden == 0) {
// If 'hidden' is 0 only the categories
// which aren't set to hidden must be changed
// because they form a hidden group themselves
// anyway and have to stay hidden
$cats = JoomHelper::getAllSubCategories($this->cid, false, true, true, true);
}
$query = $this->_db->getQuery(true)->update(_JOOM_TABLE_CATEGORIES)->set('in_hidden = ' . (int) ($this->hidden || $this->in_hidden))->where('cid IN (' . implode(',', $cats) . ')');
$this->_db->setQuery($query);
if (!$this->_db->query()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
}
return true;
}
开发者ID:naka211,项目名称:kkvn,代码行数:45,代码来源:joomgallerycategories.php
示例16: store
/**
* Overloaded store function
*
* @param boolean $updateNulls True to update fields even if they are null.
*
* @return mixed False on failure, positive integer on success.
*
* @see JTable::store()
* @since 11.1
*/
public function store($updateNulls = false)
{
$db = JFactory::getDbo();
// Verify that the alias is unique
$table = JTable::getInstance('Menu', 'JTable', array('dbo' => $this->getDbo()));
$originalAlias = trim($this->alias);
$this->alias = !$originalAlias ? $this->title : $originalAlias;
$this->alias = JApplicationHelper::stringURLSafe(trim($this->alias), $this->language);
// If alias still empty (for instance, new menu item with chinese characters with no unicode alias setting).
if (empty($this->alias)) {
$this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} else {
$itemSearch = array('alias' => $this->alias, 'parent_id' => $this->parent_id, 'client_id' => (int) $this->client_id);
$errorType = '';
// Check if the alias already exists. For multilingual site.
if (JLanguageMultilang::isEnabled()) {
// If not exists a menu item at the same level with the same alias (in the All or the same language).
if ($table->load(array_replace($itemSearch, array('language' => '*'))) && ($table->id != $this->id || $this->id == 0) || $table->load(array_replace($itemSearch, array('language' => $this->language))) && ($table->id != $this->id || $this->id == 0) || $this->language == '*' && $table->load($itemSearch) && ($table->id != $this->id || $this->id == 0)) {
$errorType = 'MULTILINGUAL';
}
} else {
// If not exists a menu item at the same level with the same alias (in any language).
if ($table->load($itemSearch) && ($table->id != $this->id || $this->id == 0)) {
$errorType = 'MONOLINGUAL';
}
}
// The alias already exists. Send an error message.
if ($errorType) {
$message = JText::_('JLIB_DATABASE_ERROR_MENU_UNIQUE_ALIAS' . ($this->menutype != $table->menutype ? '_ROOT' : ''));
$this->setError($message);
return false;
}
}
if ($this->home == '1') {
// Verify that the home page for this menu is unique.
if ($table->load(array('menutype' => $this->menutype, 'client_id' => (int) $this->client_id, 'home' => '1')) && $table->language != $this->language) {
$this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_HOME_NOT_UNIQUE_IN_MENU'));
return false;
}
// Verify that the home page for this language is unique
if ($table->load(array('home' => '1', 'language' => $this->language))) {
if ($table->checked_out && $table->checked_out != $this->checked_out) {
$this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_DEFAULT_CHECKIN_USER_MISMATCH'));
return false;
}
$table->home = 0;
$table->checked_out = 0;
$table->checked_out_time = $db->getNullDate();
$table->store();
}
}
if (!parent::store($updateNulls)) {
return false;
}
// Get the new path in case the node was moved
$pathNodes = $this->getPath();
$segments = array();
foreach ($pathNodes as $node) {
// Don't include root in path
if ($node->alias != 'root') {
$segments[] = $node->alias;
}
}
$newPath = trim(implode('/', $segments), ' /\\');
// Use new path for partial rebuild of table
// Rebuild will return positive integer on success, false on failure
return $this->rebuild($this->{$this->_tbl_key}, $this->lft, $this->level, $newPath) > 0;
}
开发者ID:adjaika,项目名称:J3Base,代码行数:78,代码来源:menu.php
示例17: store
/**
* Overriden JTable::store to set created/modified and user id.
*
* @param boolean True to update fields even if they are null.
*
* @return boolean True on success.
*
* @since 11.1
*/
public function store($updateNulls = false)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if ($this->id) {
// Existing category
$this->modified_time = $date->toMySQL();
$this->modified_user_id = $user->get('id');
} else {
// New category
$this->created_time = $date->toMySQL();
$this->created_user_id = $user->get('id');
}
// Verify that the alias is unique
$table = JTable::getInstance('Category', 'JTable');
if ($table->load(array('alias' => $this->alias, 'parent_id' => $this->parent_id, 'extension' => $this->extension)) && ($table->id != $this->id || $this->id == 0)) {
$this->setError(JText::_('JLIB_DATABASE_ERROR_CATEGORY_UNIQUE_ALIAS'));
return false;
}
return parent::store($updateNulls);
}
开发者ID:ramdesh,项目名称:joomla-platform,代码行数:30,代码来源:category.php
示例18: delete
/**
* Method to delete a node and, optionally, its child nodes from the table.
*
* @param integer $pk The primary key of the node to delete.
* @param boolean $children True to delete child nodes, false to move them up a level.
*
* @return boolean True on success.
*
* @since 3.1
*/
public function delete($pk = null, $children = false)
{
$return = parent::delete($pk, $children);
if ($return) {
$helper = new JHelperTags();
$helper->tagDeleteInstances($pk);
}
return $return;
}
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:19,代码来源:tag.php
示例19: delete
public function delete($pk = null)
{
$db = JFactory::getDbo();
$k = $this->_tbl_key;
$pk = is_null($pk) ? $this->{$k} : $pk;
$this->load($pk);
if ($this->home == 1 || $this->default == 1) {
$this->setError(JText::_('COM_JUDIRECTORY_CAN_NOT_DELETE_DEFAULT_TEMPLATE_STYLE'));
return false;
}
$defaultStyleObject = JUDirectoryFrontHelperTemplate::getDefaultTemplateStyle();
$query = $db->getQuery(true);
$query->update('#__judirectory_categories');
$query->set('style_id = -2');
if ($defaultStyleObject->template_id != $this->template_id) {
$query->set('template_params = ""');
}
$query->where('parent_id = 0');
$query->where('style_id = ' . $pk);
$db->setQuery($query);
$db->execute();
$query = $db->getQuery(true);
$query->select('id');
$query->from('#__judirectory_categories');
$query->where('style_id = ' . $pk);
$db->setQuery($query);
$categoryArrayAssignedToStyle = $db->loadColumn();
$query = $db->getQuery(true);
$query->update('#__judirectory_categories');
$query->set('style_id = -1');
$query->where('parent_id != 0');
$query->where('style_id = ' . $pk);
$db->setQuery($query);
$db->execute();
foreach ($categoryArrayAssignedToStyle as $categoryIdAssignedToStyle) {
$styleObjectOfCategory = JUDirectoryFrontHelperTemplate::getTemplateStyleOfCategory($categoryIdAssignedToStyle);
if ($styleObjectOfCategory->template_id != $this->template_id) {
$query = $db->getQuery(true);
$query->update('#__judirectory_categories');
$query->set('template_params = ""');
$query->where('id = ' . $categoryIdAssignedToStyle);
$db->setQuery($query);
$db->execute();
$query = $db->getQuery(true);
$query->update('#__judirectory_listings AS listing');
$query->set('listing.template_params = ""');
$query->join('', '#__judirectory_listings_xref AS listingxref ON listing.id = listingxref.listing_id AND listingxref.main = 1');
$query->where('listing.style_id = -1');
$query->where('listingxref.cat_id = ' . $categoryIdAssignedToStyle);
$db->setQuery($query);
$db->execute();
JUDirectoryFrontHelperTemplate::removeTemplateParamsOfInheritedStyleCatListing($categoryIdAssignedToStyle);
}
}
$query = $db->getQuery(true);
$query->select('listing.id');
$query->select('listingxref.cat_id AS cat_id');
$query->from('#__judirectory_listings AS listing');
$query->join('', '#__judirectory_listings_xref AS listingxref ON listing.id = listingxref.listing_id AND listingxref.main = 1');
$query->where('listing.style_id = ' . $pk);
$db->setQuery($query);
$listingObjectListAssignedToStyle = $db->loadObjectList();
$catArrayResetTemplateParams = array();
foreach ($listingObjectListAssignedToStyle as $listingObject) {
$styleObjectOfCategory = JUDirectoryFrontHelperTemplate::getTemplateStyleOfCategory($listingObject->cat_id);
if ($styleObjectOfCategory->template_id != $this->template_id) {
$catArrayResetTemplateParams[] = $listingObject->cat_id;
}
}
$catArrayResetTemplateParams = array_unique($catArrayResetTemplateParams);
if (is_array($catArrayResetTemplateParams) && count($catArrayResetTemplateParams)) {
$query = $db->getQuery(true);
$query->update('#__judirectory_listings AS listing');
$query->join('', '#__judirectory_listings_xref AS listingxref ON listing.id = listingxref.listing_id AND listingxref.main = 1');
$query->set('listing.template_params = ""');
$query->set('listing.style_id = -1');
$query->where('listingxref.cat_id IN (' . implode(',', $catArrayResetTemplateParams) . ')');
$query->where('listing.style_id = ' . $pk);
$db->setQuery($query);
$db->execute();
}
return parent::delete($pk);
}
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:83,代码来源:style.php
示例20: store
/**
* Overridden JTable::store to set created/modified and user id.
*
* @param boolean $updateNulls True to update fields even if they are null.
*
* @return boolean True on success.
*
* @since 11.1
*/
public function store($updateNulls = false)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if ($this->id) {
// Existing category
$this->modified_time = $date->toSql();
$this->modified_user_id = $user->get('id');
} else {
// New category
$this->created_time = $date->toSql();
$this->created_user_id = $user->get('id');
}
// Verify that the alias is unique
$table = JTable::getInstance('Category', 'JTable', array('dbo' => $this->getDbo()));
if ($table->load(array('alias' => $this->alias, 'parent_id' => $this->parent_id, 'extension' => $this->extension)) && ($table->id != $this->id || $this->id == 0)) {
$this->setError(JText::_('JLIB_DATABASE_ERROR_CATEGORY_UNIQUE_ALIAS'));
return false;
}
$this->tagsHelper->typeAlias = $this->extension . '.category';
$this->tagsHelper->preStoreProcess($this);
$result = parent::store($updateNulls);
return $result && $this->tagsHelper->postStoreProcess($this);
}
开发者ID:GitIPFire,项目名称:Homeworks,代码行数:33,代码来源:category.php
注:本文中的JTableNested类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论