本文整理汇总了PHP中JTableNested::check方法的典型用法代码示例。如果您正苦于以下问题:PHP JTableNested::check方法的具体用法?PHP JTableNested::check怎么用?PHP JTableNested::check使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JTableNested
的用法示例。
在下文中一共展示了JTableNested::check方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: check
/**
* Overloaded check function
*/
public function check()
{
//If there is an ordering column and this is a new row then get the next ordering value
if (property_exists($this, 'ordering') && $this->id == 0) {
$this->ordering = self::getNextOrder();
}
// Check alias
if (empty($this->alias)) {
$this->alias = $this->name;
}
$this->alias = JApplication::stringURLSafe($this->alias);
return parent::check();
}
示例3: check
/**
* Overloaded check function
*
* @return boolean True on success
*
* @see JTable::check()
* @since 11.1
*/
public function check()
{
try {
parent::check();
} catch (\Exception $e) {
$this->setError($e->getMessage());
return false;
}
// Check for a title.
if (trim($this->title) == '') {
$this->setError(JText::_('JLIB_DATABASE_ERROR_MUSTCONTAIN_A_TITLE_MENUITEM'));
return false;
}
// Set correct component id to ensure proper 404 messages with separator items
if ($this->type == "separator") {
$this->component_id = 0;
}
// Check for a path.
if (trim($this->path) == '') {
$this->path = $this->alias;
}
// Check for params.
if (trim($this->params) == '') {
$this->params = '{}';
}
// Check for img.
if (trim($this->img) == '') {
$this->img = ' ';
}
// Cast the home property to an int for checking.
$this->home = (int) $this->home;
// Verify that a first level menu item alias is not 'component'.
if ($this->parent_id == 1 && $this->alias == 'component') {
$this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_ROOT_ALIAS_COMPONENT'));
return false;
}
// Verify that a first level menu item alias is not the name of a folder.
jimport('joomla.filesystem.folder');
if ($this->parent_id == 1 && in_array($this->alias, JFolder::folders(JPATH_ROOT))) {
$this->setError(JText::sprintf('JLIB_DATABASE_ERROR_MENU_ROOT_ALIAS_FOLDER', $this->alias, $this->alias));
return false;
}
// Verify that the home item a component.
if ($this->home && $this->type != 'component') {
$this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_HOME_NOT_COMPONENT'));
return false;
}
return true;
}
示例4: check
/**
* Checks that the object is valid and able to be stored.
*
* This method checks that the parent_id is non-zero and exists in the database.
* Note that the root node (parent_id = 0) cannot be manipulated with this class.
*
* @return boolean True if all checks pass.
*/
public function check()
{
$dispatcher = RFactory::getDispatcher();
// Import plugin types
if ($this->_eventBeforeCheck || $this->_eventAfterCheck) {
foreach ($this->_pluginTypesToImport as $type) {
JPluginHelper::importPlugin($type);
}
}
// Trigger before check
if ($this->_eventBeforeCheck) {
$results = $dispatcher->trigger($this->_eventBeforeCheck, array($this));
if (count($results) && in_array(false, $results, true)) {
return false;
}
}
// Check
if (!parent::check()) {
return false;
}
// Trigger after check
if ($this->_eventAfterCheck) {
$results = $dispatcher->trigger($this->_eventAfterCheck, array($this));
if (count($results) && in_array(false, $results, true)) {
return false;
}
}
return true;
}
示例5: check
/**
* Overloaded check method to ensure data integrity.
*
* @return boolean True on success.
*
* @since 3.1
* @throws UnexpectedValueException
*/
public function check()
{
try {
parent::check();
} catch (\Exception $e) {
$this->setError($e->getMessage());
return false;
}
// Check for valid name.
if (trim($this->title) == '') {
throw new UnexpectedValueException(sprintf('The title is empty'));
}
if (empty($this->alias)) {
$this->alias = $this->title;
}
$this->alias = JApplicationHelper::stringURLSafe($this->alias, $this->language);
if (trim(str_replace('-', '', $this->alias)) == '') {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s");
}
// Check the publish down date is not earlier than publish up.
if ((int) $this->publish_down > 0 && $this->publish_down < $this->publish_up) {
throw new UnexpectedValueException(sprintf('End publish date is before start publish date.'));
}
// Clean up keywords -- eliminate extra spaces between phrases
// and cr (\r) and lf (\n) characters from string
if (!empty($this->metakey)) {
// Only process if not empty
// Define array of characters to remove
$bad_characters = array("\n", "\r", "\"", "<", ">");
// Remove bad characters
$after_clean = JString::str_ireplace($bad_characters, "", $this->metakey);
// Create array using commas as delimiter
$keys = explode(',', $after_clean);
$clean_keys = array();
foreach ($keys as $key) {
if (trim($key)) {
// Ignore blank keywords
$clean_keys[] = trim($key);
}
}
// Put array back together delimited by ", "
$this->metakey = implode(", ", $clean_keys);
}
// Clean up description -- eliminate quotes and <> brackets
if (!empty($this->metadesc)) {
// Only process if not empty
$bad_characters = array("\"", "<", ">");
$this->metadesc = JString::str_ireplace($bad_characters, "", $this->metadesc);
}
// Not Null sanity check
$date = JFactory::getDate();
if (empty($this->params)) {
$this->params = '{}';
}
if (empty($this->metadesc)) {
$this->metadesc = '';
}
if (empty($this->metakey)) {
$this->metakey = '';
}
if (empty($this->metadata)) {
$this->metadata = '{}';
}
if (empty($this->urls)) {
$this->urls = '{}';
}
if (empty($this->images)) {
$this->images = '{}';
}
if (!(int) $this->checked_out_time) {
$this->checked_out_time = $date->toSql();
}
if (!(int) $this->modified_time) {
$this->modified_time = $date->toSql();
}
if (!(int) $this->modified_time) {
$this->modified_time = $date->toSql();
}
if (!(int) $this->publish_up) {
$this->publish_up = $date->toSql();
}
if (!(int) $this->publish_down) {
$this->publish_down = $date->toSql();
}
return true;
}
示例6: check
public function check()
{
$app = JFactory::getApplication();
if ($app->isSite()) {
$params = JUDirectoryHelper::getParams(null, $this->listing_id);
$this->_comment_interval = $params->get('comment_interval', 60);
if ($this->_comment_interval > 0) {
$this->_comment_latest = strtotime($this->getLatestCommentTime());
}
$this->_comment_interval_same_listing = $params->get('comment_interval_in_same_listing', 60);
if ($this->_comment_interval_same_listing > 0) {
$this->_comment_latest_same_listing = strtotime($this->getLatestCommentTime($this->listing_id));
}
}
if (!parent::check()) {
$this->setError(JText::_('COM_JUDIRECTORY_COMMENT_FAILED'));
return false;
}
return true;
}
示例7: check
public function check()
{
$app = JFactory::getApplication();
if ($app->isSite()) {
$params = JUDownloadHelper::getParams(null, $this->doc_id);
$this->_comment_interval = $params->get('comment_interval', 60);
if ($this->_comment_interval > 0) {
$this->_comment_latest = strtotime($this->getLatestCommentTime());
}
$this->_comment_interval_same_document = $params->get('comment_interval_in_same_document', 60);
if ($this->_comment_interval_same_document > 0) {
$this->_comment_latest_same_document = strtotime($this->getLatestCommentTime($this->doc_id));
}
}
if (!parent::check()) {
$this->setError(JText::_('COM_JUDOWNLOAD_COMMENT_FAILED'));
return false;
}
return true;
}
示例8: check
/**
* Checks that the object is valid and able to be stored.
*
* This method checks that the parent_id is non-zero and exists in the database.
* Note that the root node (parent_id = 0) cannot be manipulated with this class.
*
* @return boolean True if all checks pass.
*/
public function check()
{
// Before check
if (!$this->beforeCheck()) {
return false;
}
// Check
if (!parent::check()) {
return false;
}
// After check
if (!$this->afterCheck()) {
return false;
}
return true;
}
示例9: check
/**
* Override check function
*
* @return boolean
*
* @see JTable::check()
* @since 11.1
*/
public function check()
{
try {
parent::check();
} catch (\Exception $e) {
$this->setError($e->getMessage());
return false;
}
// Check for a title.
if (trim($this->title) == '') {
$this->setError(JText::_('JLIB_DATABASE_ERROR_MUSTCONTAIN_A_TITLE_CATEGORY'));
return false;
}
$this->alias = trim($this->alias);
if (empty($this->alias)) {
$this->alias = $this->title;
}
$this->alias = JApplicationHelper::stringURLSafe($this->alias, $this->language);
if (trim(str_replace('-', '', $this->alias)) == '') {
$this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
}
return true;
}