/**
  * Overloaded check method to ensure data integrity.
  *
  * @return  boolean  True on success.
  *
  * @since   1.5
  */
 public function check()
 {
     /*
      * Clean up keywords -- eliminate extra spaces between phrases
      * and cr (\r) and lf (\n) characters from string
      */
     if (!empty($this->metakey)) {
         // Array of characters to remove
         $bad_characters = array("\n", "\r", "\"", "<", ">");
         $after_clean = String::str_ireplace($bad_characters, "", $this->metakey);
         $keys = explode(',', $after_clean);
         $clean_keys = array();
         foreach ($keys as $key) {
             // Ignore blank keywords
             if (trim($key)) {
                 $clean_keys[] = trim($key);
             }
         }
         // Put array back together delimited by ", "
         $this->metakey = implode(", ", $clean_keys);
     }
     return true;
 }
Esempio n. 2
0
 /**
  * Overloaded check method to ensure data integrity.
  *
  * @return  boolean  True on success.
  *
  * @since   1.5
  */
 public function check()
 {
     if (JFilterInput::checkAttribute(array('href', $this->url))) {
         $this->setError(JText::_('COM_WEBLINKS_ERR_TABLES_PROVIDE_URL'));
         return false;
     }
     // check for valid name
     if (trim($this->title) == '') {
         $this->setError(JText::_('COM_WEBLINKS_ERR_TABLES_TITLE'));
         return false;
     }
     // Check for existing name
     $db = $this->getDbo();
     $query = $db->getQuery(true)->select($db->quoteName('id'))->from($db->quoteName('#__weblinks'))->where($db->quoteName('title') . ' = ' . $db->quote($this->title))->where($db->quoteName('catid') . ' = ' . (int) $this->catid);
     $db->setQuery($query);
     $xid = (int) $db->loadResult();
     if ($xid && $xid != (int) $this->id) {
         $this->setError(JText::_('COM_WEBLINKS_ERR_TABLES_NAME'));
         return false;
     }
     if (empty($this->alias)) {
         $this->alias = $this->title;
     }
     $this->alias = JApplicationHelper::stringURLSafe($this->alias);
     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 ($this->publish_down > $db->getNullDate() && $this->publish_down < $this->publish_up) {
         $this->setError(JText::_('JGLOBAL_START_PUBLISH_AFTER_FINISH'));
         return false;
     }
     /*
      * Clean up keywords -- eliminate extra spaces between phrases
      * and cr (\r) and lf (\n) characters from string
      */
     if (!empty($this->metakey)) {
         // Array of characters to remove
         $bad_characters = array("\n", "\r", "\"", "<", ">");
         $after_clean = String::str_ireplace($bad_characters, "", $this->metakey);
         $keys = explode(',', $after_clean);
         $clean_keys = array();
         foreach ($keys as $key) {
             // Ignore blank keywords
             if (trim($key)) {
                 $clean_keys[] = trim($key);
             }
         }
         // Put array back together delimited by ", "
         $this->metakey = implode(", ", $clean_keys);
     }
     return true;
 }