public function getItem()
 {
     $item = parent::getItem();
     if ($item) {
         $item->source = $this->_state->source;
     }
     return $item;
 }
예제 #2
0
 /**
  * Get a revision item
  *
  * When gettig revision number X, this method will transparently build the
  * data from revision 1 to X and return a complete row. This is done because
  * revision X always contains just the changes from the previous revision,
  * so the rest needs to be built.
  *
  * @return KDatabaseRow
  */
 public function getItem()
 {
     if (!isset($this->_item)) {
         if ($this->_state->revision > 1) {
             $this->_item = $this->getRevision();
         }
     }
     return parent::getItem();
 }
예제 #3
0
 public function getItem()
 {
     if (!isset($this->_item)) {
         $this->_item = $this->getService('com://admin/files.database.row.config');
         $container = $this->getService('com://admin/files.model.containers')->slug((string) $this->_state->container)->getItem();
         $this->_item->setData(json_decode($container->parameters, true));
         $this->_item->container = $container;
     }
     return parent::getItem();
 }
예제 #4
0
 /**
  * Get a topic row object
  *
  * @return KDatabaseRowset
  */
 public function getItem()
 {
     if (!isset($this->_item)) {
         parent::getItem();
         //@TODO acl workaround
         if (!$this->_item->forum_id && $this->_state->forum) {
             $this->_item->forum_id = $this->_state->forum;
         }
     }
     return $this->_item;
 }
예제 #5
0
 /**
  * Method to get a item object which represents a table row
  *
  * If the model state is unique a row is fetched from the database based on the state.
  * If not, an empty row is be returned instead.
  *
  * This method is customized in order to set the default module type on new rows.
  *
  * @return KDatabaseRow
  */
 public function getItem()
 {
     if (!isset($this->_item)) {
         $this->_item = parent::getItem();
         if ($this->_item->isNew() && $this->_state->type) {
             $client = JApplicationHelper::getClientInfo($this->_state->application, true);
             $this->_item->client_id = $client->id;
             $this->_item->type = $this->_state->type;
         }
     }
     return $this->_item;
 }
예제 #6
0
 public function getItem()
 {
     $state = $this->_state;
     if ($state->cache === 0 || !$state->id) {
         parent::getItem();
     } else {
         $state = $this->_state;
         $row = array_merge(unserialize($this->redis->get('event:' . $state->id)), array('cached' => 1));
         $this->_item = $this->getTable()->getRow(array('data' => $row, 'new' => false));
     }
     return $this->_item;
 }
예제 #7
0
 public function getItem()
 {
     $state = $this->getState();
     if ($state->container) {
         $container = $this->getService('com://admin/cloudinary.model.accounts')->slug($state->container)->getItem();
     } else {
         // Select default account
         $container = $this->getService('com://admin/cloudinary.model.accounts')->default(1)->getItem();
     }
     Cloudinary::config(array('cloud_name' => $container->cloud_name, 'api_key' => $container->api_key, 'api_secret' => $container->api_secret));
     // Force the path to a string so object with __toString() function will work
     $this->set('path', (string) $state->path);
     if (parent::getItem()->isNew()) {
         if (!$state->type) {
             $image = \Cloudinary\Uploader::upload(JPATH_FILES . '/' . $state->path);
         }
         $this->_item = $this->getRow()->setData(array('public_id' => $state->type ? $state->path : $image['public_id'], 'path' => $state->path, 'url' => $state->type ? '' : $image['url'], 'format' => $state->type ? '' : $image['format'], 'cloudinary_account_id' => $container->id));
         $this->_item->save();
     }
     if ($state->flags) {
         if (is_array($state->flags)) {
             $state->flags = implode('.', $state->flags);
         }
     }
     $file = $state->type ? $this->_item->public_id : $this->_item->public_id . '.' . $this->_item->format;
     $this->_item->setData(array('url' => cloudinary_url($file, $state->toArray())));
     if ($state->cache) {
         $this->_item->setData(array('url' => $this->_item->getImage($this->_item->url, $state->toArray())));
     }
     if ($state->getsize) {
         $curl = curl_init($this->_item->url);
         curl_setopt_array($curl, array(CURLOPT_HTTPHEADER => array('Range: bytes=0-32768'), CURLOPT_RETURNTRANSFER => 1));
         $image = imagecreatefromstring(curl_exec($curl));
         $this->_item->setData(array('width' => imagesx($image), 'height' => imagesy($image)));
         curl_close($curl);
     }
     $this->_item->setData(array('attribs' => KHelperArray::toString($state->attribs)));
     return $this->_item;
 }
예제 #8
0
	/**
	 * Method to get a item object which represents a table row
	 *
	 * If the model state is unique a row is fetched from the database based on the state.
	 * If not, an empty row is be returned instead.
	 *
	 * This method is customized in order to set the default module type on new rows.
	 *
	 * @return KDatabaseRow
	 */
	public function getItem()
	{
		if (!isset($this->_item))
		{
			$this->_item = parent::getItem();

			if($this->_item->isNew() && $this->_state->type) {
				$this->_item->type = $this->_state->type;
			}
		}

		return $this->_item;
	}
예제 #9
0
 function getItem()
 {
     $item = parent::getItem();
     // Initial parsing of the Excel file to determine field types
     if ($item->filename) {
         require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helper' . DS . 'BiffWorkbook.inc.php';
         // set up sanitize filter
         $config = array('separator' => '');
         $filter = KFilter::factory('slug', $config);
         try {
             $doc = new CompoundDocument('utf-8');
             $doc->parse(file_get_contents(JPATH_COMPONENT_ADMINISTRATOR . DS . 'uploads' . DS . $item->filename));
             $wb = new BiffWorkbook($doc);
             $wb->parse();
         } catch (Exception $e) {
             $app = JFactory::getApplication();
             $app->enqueueMessage($e->getMessage());
             return false;
         }
         foreach ($wb->sheets as $sheetName => $sheet) {
             for ($col = 0; $col < $sheet->cols(); $col++) {
                 if (!isset($sheet->cells[0][$col])) {
                     continue;
                 }
                 $cell = $sheet->cells[0][$col];
                 if (is_null($cell->value)) {
                     // skip column
                 } else {
                     $columnname = $filter->sanitize($cell->value);
                     $isnumeric = true;
                     $isint = true;
                     $isdate = true;
                     $strlen = 0;
                     for ($row = 1; $row < $sheet->rows(); $row++) {
                         if (!isset($sheet->cells[$row][$col])) {
                             continue;
                         }
                         if (is_null($sheet->cells[$row][$col]->value)) {
                             continue;
                         }
                         $value = $sheet->cells[$row][$col]->value;
                         if (is_numeric($value)) {
                             if (is_int($value) == false) {
                                 $isint = false;
                             }
                         } else {
                             $isnumeric = false;
                             $strlen = max($strlen, strlen($value));
                             // could it also be a date?
                             $datearr = date_parse_from_format("j/n/y", $value);
                             //needs PHP 5.3
                             if ($datearr['year'] && $datearr['month'] && $datearr['day']) {
                                 // valid date
                             } else {
                                 // no valid date
                                 $isdate = false;
                             }
                         }
                     }
                     if ($isnumeric) {
                         $columns[$columnname] = 'DECIMAL(10,2)';
                         if ($isint) {
                             $columns[$columnname] = 'INT(11)';
                         }
                     } else {
                         if ($isdate) {
                             $columns[$columnname] = 'DATE';
                         } else {
                             $columns[$columnname] = 'VARCHAR (' . $strlen . ')';
                         }
                     }
                 }
             }
         }
         $item->columns = $columns;
     }
     $this->_item = $item;
     return $item;
 }
예제 #10
0
    /**
     * Method to get a item object which represents a table row
     *
     * Overridden to add itemid to the returned results
     *
     * @return KDatabaseRowInterface
     */
    public function getItem()
    {
        $item = parent::getItem();

        if ($item) {
            $item->itemid = $this->_findPage($item);
        }

        return $item;
    }
예제 #11
0
 public function getItem()
 {
     if (!$this->_item) {
         $identifier = $this->getIdentifier();
         $isNotSetting = KRequest::get('get.view', 'cmd') != 'setting';
         $params = array();
         if (!KFactory::get('lib.joomla.application')->isAdmin()) {
             $menus = JSite::getMenu();
             $menu = $menus->getActive() ? $menus->getActive() : $menus->getDefault();
             $settings = new JParameter($menu->params);
             $params = (array) $settings->_registry['_default']['data'];
             $pk = KFactory::get($this->getTable())->getPrimaryKey();
             $name = $pk['id']->name;
             $id = !empty($params[$name]) ? $params[$name] : false;
             if ($id) {
                 $table = $this->getTable();
                 $item = $table->select($id, KDatabase::FETCH_ROW);
             } else {
                 if ($isNotSetting) {
                     $item = $this->getDefault();
                 }
             }
         } else {
             if ($isNotSetting) {
                 $item = $this->getDefault();
             } else {
                 $item = parent::getItem();
             }
         }
         $item->params->append($params);
         $item->xml = simplexml_load_file($this->getTable()->getXMLPath());
         $this->_item = $item;
     }
     return $this->_item;
 }