コード例 #1
0
ファイル: Model.php プロジェクト: mined-gatech/framework
 /**
  * Bind data to the model
  *
  * @param   mixed    $data  Object or array
  * @return  boolean  True on success, False on error
  */
 public function bind($data = null)
 {
     if (is_object($data)) {
         $res = $this->_tbl->bind($data);
         if ($res) {
             $properties = $this->_tbl->getProperties();
             foreach (get_object_vars($data) as $key => $property) {
                 if (!array_key_exists($key, $properties)) {
                     $this->_tbl->set('__' . $key, $property);
                 }
             }
         }
     } else {
         if (is_array($data)) {
             $res = $this->_tbl->bind($data);
             if ($res) {
                 $properties = $this->_tbl->getProperties();
                 foreach (array_keys($data) as $key) {
                     if (!array_key_exists($key, $properties)) {
                         $this->_tbl->set('__' . $key, $data[$key]);
                     }
                 }
             }
         } else {
             $this->_logError(__CLASS__ . '::' . __FUNCTION__ . '(); ' . \Lang::txt('Data must be of type object or array. Type given was %s', gettype($data)));
             throw new \InvalidArgumentException(\Lang::txt('Data must be of type object or array. Type given was %s', gettype($data)));
         }
     }
     return $res;
 }
コード例 #2
0
ファイル: driver.php プロジェクト: kanikaN/qload
 /**
  * Render a view from a field or form object
  *
  * @access public
  * @return void
  */
 public function render($view_file = FALSE, $view_prefix = NULL)
 {
     if ($this->_field->get('render', NULL) === FALSE) {
         return;
     }
     // First run and do any pre_render stuff
     $this->pre_render();
     // Prefix acts as a templating system for views
     $prefix = $this->_get_view_prefix($view_prefix);
     // Determine the view file
     $view = $this->_get_view($view_file);
     // Skip the prefix if view prefix is FALSE
     $skip_prefix = $view_prefix === FALSE;
     $this->_view->bind('open', $open)->bind('close', $close)->bind('message', $message)->bind('label', $label);
     $prefix = rtrim($prefix, '/');
     $open = Formo_View::factory("{$prefix}/_open_tag", array('view' => $this->_view));
     $open->_field = $this->_field;
     $close = Formo_View::factory("{$prefix}/_close_tag", array('view' => $this->_view));
     $close->_field = $this->_field;
     $message = Formo_View::factory("{$prefix}/_message", array('view' => $this->_view));
     $message->_field = $this->_field;
     $label = Formo_View::factory("{$prefix}/_label", array('view' => $this->_view));
     $label->_field = $this->_field;
     return $this->_view->render("{$prefix}/{$view}");
 }
コード例 #3
0
ファイル: basemodel.php プロジェクト: lautarodragan/ideary
 public function setData($data)
 {
     // get a table instance
     $this->_data =& JTable::getInstance($this->_defaultTable, 'Sh404sefTable');
     // bind data
     $this->_data->bind($data);
 }
コード例 #4
0
ファイル: join.php プロジェクト: LGBGit/tierno
 /**
  * Get Join
  *
  * @return  FabrikTableJoin
  */
 public function getJoin()
 {
     if (!isset($this->join)) {
         $this->join = FabTable::getInstance('join', 'FabrikTable');
         if (isset($this->data)) {
             $this->join->bind($this->data);
         } else {
             $this->join->load($this->id);
         }
         $this->paramsType($this->join);
     }
     return $this->join;
 }
コード例 #5
0
ファイル: Utilisateur.class.php プロジェクト: cmahneke/origin
 /**
  * @brief Méthode qui récupère les artistes d'une oeuvre.
  * @param int $idOeuvre
  * @access public
  * @return array
  */
 public function getOeuvresVisiter($idUtilisateur)
 {
     $infoVisite = array();
     self::$database->query('SELECT * FROM oeuvres JOIN visitent ON visitent.idOeuvre = oeuvres.idOeuvre WHERE visitent.idUtilisateur = :idUtilisateur');
     self::$database->bind(':idUtilisateur', $idUtilisateur);
     if ($lignes = self::$database->resultset()) {
         foreach ($lignes as $oeuvres) {
             $uneOeuvre = array("titre" => $oeuvres["titre"], "idOeuvre" => $oeuvres["idOeuvre"]);
             $infoVisite[] = $uneOeuvre;
         }
     }
     return $infoVisite;
 }
コード例 #6
0
 /**
  * The routing strategy, it creates all necessary routes to match RESTFul URLs for the
  * provided resource name.
  *
  * @param object $router   The router instance.
  * @param string $resource The resource name.
  * @param array  $options  The options array.
  */
 public function __invoke($router, $resource, $options = [])
 {
     $options += ['name' => $resource, 'key' => $this->_key, 'format' => $this->_format, 'rkey' => $this->_rkey, 'rformat' => $this->_format, 'action' => ':{action}'];
     $slug = Inflector::dasherize(Inflector::underscore($resource));
     $path = '{resource:' . $slug . '}';
     $placeholder = '{id:' . $options['format'] . '}';
     $rplaceholder = '{rid:' . $options['rformat'] . '}';
     $pattern = '[{relation}/' . $rplaceholder . '/]' . $path . '[/' . $placeholder . ']' . '[/' . $options['action'] . ']';
     $options['params'] = ['resource' => $slug];
     return $router->bind($pattern, $options, function ($route) use($router, $resource, $options) {
         return $this->dispatch($resource, $route, $router, $options);
     });
 }
コード例 #7
0
ファイル: Photo.class.php プロジェクト: cmahneke/origin
 /**
  * @brief Méthode qui supprime une photo de la BDD.
  * @param integer $id
  * @access public
  * @return array
  */
 public function supprimerPhoto($id)
 {
     $msgErreurs = array();
     try {
         self::$database->query('DELETE FROM Photos WHERE idPhoto = :id');
         self::$database->bind(':id', $id);
         $erreur = self::$database->execute();
         if ($erreur) {
             $msgErreurs["errRequeteSupp"] = $erreur;
         }
     } catch (Exception $e) {
         $msgErreurs["errRequeteSupp"] = $e->getMessage();
     }
     return $msgErreurs;
 }
コード例 #8
0
ファイル: configuration.php プロジェクト: Simarpreet05/joomla
 /**
  * Returns the configuration object
  *
  * @return object	JParameter object
  **/
 public function getParams()
 {
     // Test if the config is already loaded.
     if (!$this->_params) {
         jimport('joomla.filesystem.file');
         $ini = JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_community' . DS . 'default.ini';
         $data = JFile::read($ini);
         // Load default configuration
         $this->_params = new CParameter($data);
         $config =& JTable::getInstance('configuration', 'CommunityTable');
         $config->load('config');
         // Bind the user saved configuration.
         $this->_params->bind($config->params);
     }
     return $this->_params;
 }
コード例 #9
0
ファイル: basemodel.php プロジェクト: alesconti/FF_2015
 public function setData($data)
 {
     // get a table instance
     $this->_data = JTable::getInstance($this->_defaultTable, 'Sh404sefTable');
     // bind data
     try {
         $this->_data->bind($data);
     } catch (Exception $e) {
         ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
         $this->_data->setError($e->getMessage());
     }
     // set error
     $error = $this->_data->getError();
     if (!empty($error)) {
         $this->setError($error);
     }
 }
コード例 #10
0
ファイル: user.php プロジェクト: joomline/Joomla1.5.999
 /**
  * Method to bind an associative array of data to a user object
  *
  * @access 	public
  * @param 	array 	$array 	The associative array to bind to the object
  * @return 	boolean 		True on success
  * @since 1.5
  */
 function bind(&$array)
 {
     jimport('joomla.user.helper');
     // Lets check to see if the user is new or not
     if (empty($this->id)) {
         // Check the password and create the crypted password
         if (empty($array['password'])) {
             $array['password'] = JUserHelper::genRandomPassword();
             $array['password2'] = $array['password'];
         }
         if ($array['password'] != $array['password2']) {
             $this->setError(JText::_('PASSWORD DO NOT MATCH.'));
             return false;
         }
         $this->password_clear = JArrayHelper::getValue($array, 'password', '', 'string');
         $salt = JUserHelper::genRandomPassword(32);
         $crypt = JUserHelper::getCryptedPassword($array['password'], $salt);
         $array['password'] = $crypt . ':' . $salt;
         // Set the registration timestamp
         $now =& JFactory::getDate();
         $this->set('registerDate', $now->toMySQL());
         // Check that username is not greater than 150 characters
         $username = $this->get('username');
         if (strlen($username) > 150) {
             $username = substr($username, 0, 150);
             $this->set('username', $username);
         }
         // Check that password is not greater than 100 characters
         $password = $this->get('password');
         if (strlen($password) > 100) {
             $password = substr($password, 0, 100);
             $this->set('password', $password);
         }
     } else {
         // Updating an existing user
         if (!empty($array['password'])) {
             if ($array['password'] != $array['password2']) {
                 $this->setError(JText::_('PASSWORD DO NOT MATCH.'));
                 return false;
             }
             $this->password_clear = JArrayHelper::getValue($array, 'password', '', 'string');
             $salt = JUserHelper::genRandomPassword(32);
             $crypt = JUserHelper::getCryptedPassword($array['password'], $salt);
             $array['password'] = $crypt . ':' . $salt;
         } else {
             $array['password'] = $this->password;
         }
     }
     // TODO: this will be deprecated as of the ACL implementation
     $db =& JFactory::getDBO();
     $gid = array_key_exists('gid', $array) ? $array['gid'] : $this->get('gid');
     $query = 'SELECT name' . ' FROM #__core_acl_aro_groups' . ' WHERE id = ' . (int) $gid;
     $db->setQuery($query);
     $this->set('usertype', $db->loadResult());
     if (array_key_exists('params', $array)) {
         $params = '';
         $this->_params->bind($array['params']);
         if (is_array($array['params'])) {
             $params = $this->_params->toString();
         } else {
             $params = $array['params'];
         }
         $this->params = $params;
     }
     // Bind the array
     if (!$this->setProperties($array)) {
         $this->setError("Unable to bind array to user object");
         return false;
     }
     // Make sure its an integer
     $this->id = (int) $this->id;
     return true;
 }
コード例 #11
0
ファイル: user.php プロジェクト: ppantilla/bbninja
 /**
  * Bind an array of data to the current user.
  *
  * @since	1.0
  * @access	public
  * @param	Array	The object's properties.
  * @param	bool	Determines whether the data is from $_POST method.
  *
  * @return 	bool	True if success false otherwise.
  */
 public function bind(&$data, $post = false)
 {
     // Request the helper to bind specific additional details
     $this->helper->bind($this, $data);
     // Request the parent to bind the data for us.
     // parent::bind( $data );
     // No longer use JUser to bind, as the bind should happen in SocialUser::save instead
     // We set the properties into this class instead so that SocialUser::save can get the correct properties
     // See SocialUser::save on why we bind there instead.
     $this->setProperties($data);
 }
コード例 #12
0
ファイル: Oeuvre.class.php プロジェクト: cmahneke/origin
 /**
  * @brief Méthode pour insérer une oeuvre dans la bdd
  * @param string $type
  * @param integer $idOeuvre, $idUtilisateur, $laDate
  * @access public    
  */
 public function visiteOeuvre($idOeuvre, $idUtilisateur, $laDate)
 {
     self::$database->query('INSERT INTO visitent (idOeuvre, idUtilisateur, dateVisite) VALUES (:idOeuvre, :idUtilisateur, :laDate)');
     self::$database->bind(':idOeuvre', $idOeuvre);
     self::$database->bind(':idUtilisateur', $idUtilisateur);
     self::$database->bind(':laDate', $laDate);
     self::$database->execute();
 }
コード例 #13
0
ファイル: Basic.php プロジェクト: kevinwojo/framework
 /**
  * Builds the given string representation of the value object
  *
  * @param   object  $syntax  The syntax object with which the query is being built
  * @return  string
  * @since   2.1.0
  **/
 public function build($syntax)
 {
     $syntax->bind(is_string($this->content) ? trim($this->content) : $this->content);
     return '?';
 }
コード例 #14
0
ファイル: upload.php プロジェクト: pabloarias/JoomGallery
 /**
  * Creates the database entry for a successfully uploaded image
  *
  * @param   object  $row          The JTable object of the images table to work with
  * @param   string  $origfilename The original file name of the uploaded image
  * @param   string  $newfilename  The new file name for the image
  * @param   string  $tag          The extension of the uploaded image
  * @param   int     $serial       The counter for the numbering of the image titles
  * @return  boolean True on success, false otherwise
  * @since   1.5.7
  */
 protected function registerImage($row, $origfilename, $newfilename, $tag, $serial = null)
 {
     // Get the specified image information (either from session or from post)
     $old_info = $this->_mainframe->getUserState('joom.upload.post');
     $cur_info = !is_null($old_info) ? $old_info : array();
     $new_info = JRequest::get('post');
     // Prevent setting access level in frontend
     if (isset($new_info['access']) && $this->_site) {
         unset($new_info['access']);
     }
     // Save the new value only if it was set in this request
     if (count($new_info)) {
         $this->_mainframe->setUserState('joom.upload.post', $new_info);
         $data = $new_info;
     } else {
         $data = $cur_info;
     }
     if (!$row->bind($data)) {
         $this->_debugoutput .= $row->getError();
         $this->debug = true;
         return false;
     }
     // Image title
     if ($this->_site && $this->_config->get('jg_useruseorigfilename') || !$this->_site && $this->_config->get('jg_useorigfilename')) {
         $taglength = strlen($tag);
         $filenamelength = strlen($origfilename);
         $row->imgtitle = substr($origfilename, -$filenamelength, -$taglength - 1);
     }
     // Add counter number if set in backend
     if (!is_null($serial)) {
         $imgname_separator = JText::_('COM_JOOMGALLERY_UPLOAD_IMAGENAME_SEPARATOR');
         if ($imgname_separator == 'space') {
             $imgname_separator = ' ';
         }
         $row->imgtitle = $row->imgtitle . $imgname_separator . $serial;
     }
     // Owner
     if ($this->_site) {
         $row->owner = $this->_user->get('id');
     } else {
         $row->owner = 0;
     }
     // Date
     $date = JFactory::getDate();
     $row->imgdate = $date->toSQL();
     // Check whether images are approved directly if we are in frontend
     if ($this->_site && $this->_config->get('jg_approve') == 1) {
         $row->approved = 0;
     } else {
         $row->approved = 1;
     }
     $row->imgfilename = $newfilename;
     $row->imgthumbname = $newfilename;
     $row->useruploaded = intval($this->_site);
     $row->ordering = $this->_getOrdering($row);
     if (!$row->check()) {
         $this->_debugoutput .= $row->getError() . '<br />';
         $this->debug = true;
         return false;
     }
     if (!$row->store()) {
         $this->_debugoutput .= $row->getError() . '<br />';
         $this->debug = true;
         return false;
     }
     return true;
 }