Example #1
0
 protected function _get_datasource($ds_id)
 {
     $ds = Datasource_Section::load($ds_id);
     if ($ds === NULL) {
         throw HTTP_API_Exception::factory(API::ERROR_UNKNOWN, 'Datasource section not found');
     }
     return $ds;
 }
Example #2
0
 /**
  * Метод используется для поиска по документам по ключевому слову.
  * 
  * Ключевое слово передается в качестве $_GET запроса с ключем "keyword"
  * 
  * @param Database_Query $query
  * @return Database_Query
  */
 public function search_by_keyword(Database_Query $query)
 {
     $keyword = Request::initial()->query('keyword');
     if (empty($keyword)) {
         return $query;
     }
     if ($this->_section->is_indexable()) {
         $ids = Search::instance()->find_by_keyword($keyword, FALSE, 'ds_' . $this->_section->id(), NULL);
         $ids = Arr::get($ids, 'ds_' . $this->_section->id());
         if (!empty($ids)) {
             $query->where('d.id', 'in', array_keys($ids));
         } else {
             $query->where('d.id', '=', 0);
         }
     } else {
         $query->where_open()->where('d.id', 'like', '%' . $keyword . '%')->or_where('d.header', 'like', '%' . $keyword . '%')->where_close();
     }
     return $query;
 }
Example #3
0
 /**
  * Получение списка заголовков документов
  * 
  * @param integer $ds_id
  * @param array $ids
  * @return array
  */
 public static function get_document_headers($ds_id, array $ids)
 {
     $result = array();
     foreach ($ids as $i => $id) {
         if (isset(self::$_cached_headers[$ds_id][$id])) {
             $result[$id] = self::$_cached_headers[$ds_id][$id];
             unset($ids[$i]);
         }
     }
     if (empty($ids)) {
         return $result;
     }
     $ds = Datasource_Section::load($ds_id);
     if (!$ds instanceof Datasource_Section) {
         return array();
     }
     $db_result = DB::select('id', 'header')->from($ds->table())->where('id', 'in', $ids)->execute()->as_array('id', 'header');
     foreach ($db_result as $id => $header) {
         self::$_cached_headers[$ds_id][$id] = $header;
         $result[$id] = $header;
     }
     return $result;
 }
Example #4
0
<?php

echo Form::open(Request::current()->uri(), array('class' => 'form-horizontal panel'));
?>
	<?php 
echo Form::hidden('ds_id', $ds->id());
?>
	
	<?php 
echo View::factory('datasource/section/information_form', array('users' => $users, 'ds' => $ds));
?>
	
	<div class="form-actions panel-footer">
		<?php 
echo UI::actions(NULL, Datasource_Section::uri());
?>
	</div>
<?php 
echo Form::close();
Example #5
0
function recurse_menu($id, $section, $ds_id)
{
    if (!$section->has_access_view()) {
        return;
    }
    $result = '';
    $selected = $id == $ds_id ? 'active' : '';
    $title = $section->name;
    $result .= '<li class="' . $selected . '" data-id="' . $id . '">';
    $result .= HTML::anchor(Datasource_Section::uri('view', $id), $section->name . UI::icon('ellipsis-v fa-lg', array('class' => 'pull-right section-draggable')), array('data-icon' => $section->icon()));
    $result .= '</li>';
    return $result;
}
Example #6
0
 /**
  * 
  * @param Datasource_Document $datasource
  */
 public function __construct(Datasource_Section $datasource)
 {
     $this->_datasource = $datasource;
     $this->_ds_id = (int) $datasource->id();
     $this->load();
 }
Example #7
0
 protected function _initialize()
 {
     parent::_initialize();
     $this->_record = NULL;
     $this->_agent = NULL;
     $this->indexed_doc_query = NULL;
 }
Example #8
0
 /**
  * 
  * @return array [$section, $docs, $fields, $count]
  */
 public function fetch_data()
 {
     if (!$this->ds_id) {
         return array();
     }
     list($docs, $fields) = $this->get_documents();
     return array('section' => Datasource_Section::load($this->ds_id), 'docs' => $docs, 'fields' => $fields, 'count' => count($this->docs));
 }
Example #9
0
 /**
  * 
  * @param Datasource_Section $ds
  */
 private function _edit($ds)
 {
     $data = $this->request->post();
     try {
         $ds->values($data);
         $ds->update();
     } catch (Validation_Exception $e) {
         Messages::errors($e->errors('validation'));
         $this->go_back();
     } catch (DataSource_Exception_Section $e) {
         Messages::errors($e->getMessage());
         $this->go_back();
     }
     Messages::success(__('Datasource has been saved!'));
     // save and quit or save and continue editing?
     if ($this->request->post('commit') !== NULL) {
         $this->go(Route::get('datasources')->uri(array('directory' => 'datasources', 'controller' => 'data')) . URL::query(array('ds_id' => $ds->id()), FALSE));
     } else {
         $this->go_back();
     }
 }
Example #10
0
<div class="mail-container-header">
	<?php 
echo UI::icon($datasource->icon());
?>
 <?php 
echo $datasource->name;
?>
	
	<div class="btn-group pull-right">
		<?php 
if ($datasource->has_access_edit()) {
    echo UI::button(NULL, array('href' => Datasource_Section::uri('edit', $datasource->id()), 'icon' => UI::icon('wrench'), 'class' => 'btn btn-default', 'title' => __('Edit'), 'hotkeys' => 'ctrl+e'));
}
if ($datasource->has_access_remove()) {
    echo UI::button(NULL, array('href' => Datasource_Section::uri('remove', $datasource->id()), 'icon' => UI::icon('trash-o fa-inverse'), 'class' => 'btn btn-danger btn-confirm', 'title' => __('Remove')));
}
?>
	</div>
</div>
<div class="mail-controls clearfix headline-actions">
	<?php 
echo View::factory('datasource/section/actions');
?>
</div>
<?php 
if (isset($toolbar)) {
    ?>
<div class="mail-controls">
<?php 
    echo $toolbar;
    ?>
Example #11
0
 /**
  * 
  * @param string $type
  * @return string
  */
 public static function get_icon($type)
 {
     $class_name = 'DataSource_Section_' . ucfirst($type);
     if (class_exists($class_name)) {
         return call_user_func($class_name . '::default_icon');
     }
     return Datasource_Section::default_icon();
 }