protected function _getActivityData(KDatabaseRowAbstract $row, $status, KCommandContext $context) { $clone = clone $row; // Use container:path as row identifier. $clone->id = $row->container->slug . ':' . $row->path; $data = parent::_getActivityData($clone, $status, $context); $data['metadata'] = array('image' => $row->isImage(), 'width' => $row->width, 'height' => $row->height, 'size' => $row->size, 'name' => $row->name, 'folder' => $row->folder, 'path' => $row->path, 'container' => array('id' => $row->container->id, 'slug' => $row->container->slug, 'title' => $row->container->title)); return $data; }
protected function _getStatus(KDatabaseRowAbstract $row, $action) { $status = $row->getStatus(); // Only log download events for logged in users if ($action == 'after.read' && empty($status)) { $status = JFactory::getUser()->guest ? null : 'downloaded'; } return $status; }
/** * Table insert method * * @param object A KDatabaseRow object * @return boolean TRUE if successfull, otherwise false */ public function insert(KDatabaseRowAbstract $row) { $query = $this->_database->getQuery(); $query->where('tbl.name', '=', $row->name, 'or'); if ($this->count($query)) { $asset = $this->select($query, KDatabase::FETCH_ROW); $data = array_merge($asset->getData(), array_filter($row->getData())); return parent::update($asset->setData($data)); } return parent::insert($row); }
public function delete() { $result = $this->_uninstallKoowaComponent(); if ($result) { $result = KDatabaseRowAbstract::delete(); } return $result; }
public function toArray() { $data = parent::toArray(); foreach ($this->_comma_separated->toArray() as $column) { $data[$column] = $this->{$column}; } return $data; }
protected function _initialize(KConfig $config) { $config->append(array( 'identity_column' => 'name' )); parent::_initialize($config); }
protected function _initialize(KConfig $config) { if (empty($config->adapters)) { $config->adapters = array('curl', 'fsockopen', 'fopen'); } elseif (is_string($config->adapters)) { $config->adapters = array($config->adapters); } parent::_initialize($config); }
/** * Initializes the options for the object * * Called from {@link __construct()} as a first step of object instantiation. * * @param object An optional KConfig object with configuration options. * @return void */ protected function _initialize(KConfig $config) { $config->append(array( 'children' => null, 'parent' => null, )); parent::_initialize($config); }
/** * Initializes the options for the object * * Called from {@link __construct()} as a first step of object instantiation. * * @param object An optional KConfig object with configuration options. * @return void */ protected function _initialize(KConfig $config) { $config->append(array( 'new' => false, 'name' => 'system', 'path' => '', )); parent::_initialize($config); }
/** * Return an associative array of the data. * * @return array */ public function toArray() { $data = parent::toArray(); //Include the manifest fields foreach (self::$_manifest_fields as $field) { $data[$field] = (string) $this->{$field}; } $data['name'] = (string) $this->name; $data['title'] = (string) $this->title; unset($data['path']); return $data; }
public function __get($column) { if ($column == 'extension') { return pathinfo($this->path, PATHINFO_EXTENSION); } if ($column == 'filename') { return pathinfo($this->path, PATHINFO_BASENAME); } if ($column == 'fullpath') { return $this->path; } if ($column == 'scheme') { return parse_url($this->path, PHP_URL_SCHEME); } return parent::__get($column); }
public function __get($column) { if (in_array($column, $this->_comma_separated->toArray())) { if (isset($this->_data[$column]) && is_string($this->_data[$column])) { $values = array(); if (!empty($this->_data[$column])) { $values = explode(',', $this->_data[$column]); } $this->_data[$column] = $values; } else return array(); } return parent::__get($column); }
public function toArray() { $data = parent::toArray(); unset($data['_token']); unset($data['action']); unset($data['option']); unset($data['format']); unset($data['view']); $data['container'] = $this->container->slug; $data['type'] = $this->getIdentifier()->name; return $data; }
public function __call($method, $arguments) { if (method_exists($this->_message, $method)) { call_user_func_array(array($this->_message, $method), $arguments); return $this; } else { return parent::__call($method, $arguments); } //return method_exists($this->_message, $method) ? $this->_message->$method : parent::__call($method, $arguments); }
/** * Search the mixin method map and call the method or trigger an error * * This functions overloads KDatabaseRowAbstract::__call and implements * a just in time mixin strategy. Available table behaviors are only mixed * when needed. * * @param string The function name * @param array The function arguments * @throws BadMethodCallException If method could not be found * @return mixed The result of the function */ public function __call($method, array $arguments) { if ($this->isConnected()) { $parts = KInflector::explode($method); //Check if a behavior is mixed if ($parts[0] == 'is' && isset($parts[1])) { if (!isset($this->_mixed_methods[$method])) { //Lazy mix behaviors $behavior = strtolower($parts[1]); if ($this->getTable()->hasBehavior($behavior)) { $this->mixin($this->getTable()->getBehavior($behavior)); return true; } return false; } return true; } } return parent::__call($method, $arguments); }
public function __set($column, $value) { if (in_array($column, array('path', 'basepath', 'name'))) { unset($this->size); unset($this->mimetype); } if ($column == 'name') { $path = dirname($this->_data['path']); $path .= '/'.$value; $this->_data['path'] = $path; } else if ($column == 'parent') { $this->_data['parent'] = trim($value, '\\/'); } else parent::__set($column, $value); }
public function getData($modified = false) { $result = parent::getData($modified); if (isset($result['children']) && $result['children'] instanceof KDatabaseRowsetInterface) { $result['children'] = $result['children']->getData(); } return $result; }
/** * Reset the row data using the defaults * * @return boolean If successfull return TRUE, otherwise FALSE */ public function reset() { $result = parent::reset(); if ($this->isConnected()) { // TODO: Get defaults from the row's field definition /* if($this->_data = $this->getDefaults()) { $result = true; } */ $result = true; } return $result; }
/** * Get the entity key * * @return string */ public function getIdentityKey() { return parent::getIdentityColumn(); }
/** * Status getter. * * Loggable support actions other than add, edit and delete. While logging custom actions it may be * useful to somehow translate the returned status to something more meaningful. * * @param KDatabaseRowAbstract $row * @param string $action The command action being executed. */ protected function _getStatus(KDatabaseRowAbstract $row, $action) { $status = $row->getStatus(); // Commands may change the original status of an action. if ($action == 'after.add' && $status == KDatabase::STATUS_UPDATED) { $status = KDatabase::STATUS_CREATED; } return $status; }
/** * Search the mixin method map and call the method or trigger an error * * This functions overloads KDatabaseRowAbstract::__call and implements * a just in time mixin strategy. Available table behaviors are only mixed * when needed. * * @param string The function name * @param array The function arguments * @throws BadMethodCallException If method could not be found * @return mixed The result of the function */ public function __call($method, array $arguments) { // If the method hasn't been mixed yet, load all the behaviors. if (!isset($this->_mixed_methods[$method])) { foreach ($this->getTable()->getBehaviors() as $behavior) { $this->mixin($behavior); } } return parent::__call($method, $arguments); }
public function __get($column) { $result = parent::__get($column); if (in_array($column, array('allowed_extensions', 'allowed_mimetypes')) && !is_array($result)) { return array(); } return $result; }