Example #1
2
 public function import($entity)
 {
     $appHelper = new libs\AppHelper();
     $className = $appHelper->getNameSpace() . $entity;
     $model = new $className();
     $table = $model->getTable();
     $columns = \Schema::getColumnListing($table);
     $key = $model->getKeyName();
     $notNullColumnNames = array();
     $notNullColumnsList = \DB::select(\DB::raw("SHOW COLUMNS FROM `" . $table . "` where `Null` = 'no'"));
     if (!empty($notNullColumnsList)) {
         foreach ($notNullColumnsList as $notNullColumn) {
             $notNullColumnNames[] = $notNullColumn->Field;
         }
     }
     $status = \Input::get('status');
     $filePath = null;
     if (\Input::hasFile('import_file') && \Input::file('import_file')->isValid()) {
         $filePath = \Input::file('import_file')->getRealPath();
     }
     if ($filePath) {
         \Excel::load($filePath, function ($reader) use($model, $columns, $key, $status, $notNullColumnNames) {
             $this->importDataToDB($reader, $model, $columns, $key, $status, $notNullColumnNames);
         });
     }
     $importMessage = $this->failed == true ? \Lang::get('panel::fields.importDataFailure') : \Lang::get('panel::fields.importDataSuccess');
     return \Redirect::to('panel/' . $entity . '/all')->with('import_message', $importMessage);
 }
Example #2
0
 public function getMsg(Lang $lang = null)
 {
     if (!$lang) {
         return implode('|', $this->args);
     }
     return $lang->getPhraseByArray($this->args);
 }
Example #3
0
 /**
  * @param $field
  * @param null|string $lang
  * @return string
  */
 public static function lang($field, $lang = 'ru')
 {
     if (isset($_GET['lang'])) {
         $lang = $_GET['lang'];
     }
     if (self::$langObj === null) {
         self::$langObj = new Lang($lang);
     }
     return self::$langObj->getField($field);
 }
Example #4
0
 /**
  * Return the comments for a strip
  *
  * @param Strip $strip The strip for which we want obtain the comments
  * @param Lang $lang The language object is use when the connection with forum isn't ok
  * @access public
  * @static
  * @return string The comments for the strip or an error message if the connection with forum isn't ok
  */
 public static function getComments(Strip $strip, Lang $lang)
 {
     $url = Config::getFluxbbForum() . '/extern.php?action=topic&ttitle=' . urlencode($strip->getTitle()) . '&max_subject_length=' . Config::getFluxbbMaxLength();
     $text = file_get_contents($url);
     if ($text === false) {
         $text = $lang->getForumError();
     } else {
         $text = utf8_encode($text);
     }
     return $text;
 }
 /**
  * Retourne l'ID de la langue par défaut. Pour améliorer les perfs, on cache cet ID
  * dans une variable statique.
  */
 public function get_id_langue_defaut()
 {
     if ($this->id_langue_defaut === false) {
         $lang = new Lang();
         if ($lang->charger_defaut()) {
             $this->id_langue_defaut = $lang->id;
         } else {
             $this->id_langue_defaut = 1;
         }
     }
     return $this->id_langue_defaut;
 }
Example #6
0
 public function actionIndex()
 {
     $this->hasPrivilege(Acl::ACTION_VIEW);
     $this->pageTitle = Lang::t(Common::pluralize($this->resourceLabel));
     $searchModel = Dept::model()->searchModel(array(), $this->settings[Constants::KEY_PAGINATION], 'name');
     $this->render('default/index', array('model' => $searchModel));
 }
Example #7
0
 /**
  * Generate macro output
  *
  * @return     string
  */
 public function render()
 {
     // check if we can render
     if (!parent::canRender()) {
         return \Lang::txt('[This macro is designed for Groups only]');
     }
     // get args
     $args = $this->getArgs();
     //array of filters
     $filters = array('limit' => count($args) == 1 && is_numeric($args[0]) ? $args[0] : 12);
     // get members
     $members = $this->getGroupMembers($this->group, $filters);
     //are we a group member
     $isMember = in_array(\User::get('id'), $this->group->get('members')) ? true : false;
     //get the members plugin access for this group
     $memberAccess = \Hubzero\User\Group\Helper::getPluginAccess($this->group, 'members');
     // make sure we can actually display for the current user
     if ($memberAccess == 'anyone' || $memberAccess == 'registered' && !\User::isGuest() || $memberAccess == 'members' && $isMember) {
         $html = $this->renderMembers($this->group, $members);
     } else {
         $html = '';
     }
     //return rendered events
     return $html;
 }
Example #8
0
 /**
  * Prepares the document.
  *
  * @since	1.6
  */
 protected function prepareDocument()
 {
     $menus = \App::get('menu');
     $title = null;
     // Because the application sets a default page title,
     // we need to get it from the menu item itself
     $menu = $menus->getActive();
     if ($menu) {
         $this->params->def('page_heading', $this->params->get('page_title', $menu->title));
     } else {
         $this->params->def('page_heading', Lang::txt('COM_USERS_RESET'));
     }
     $title = $this->params->get('page_title', '');
     if (empty($title)) {
         $title = Config::get('sitename');
     } elseif (Config::get('sitename_pagetitles', 0) == 1) {
         $title = Lang::txt('JPAGETITLE', Config::get('sitename'), $title);
     } elseif (Config::get('sitename_pagetitles', 0) == 2) {
         $title = Lang::txt('JPAGETITLE', $title, Config::get('sitename'));
     }
     $this->document->setTitle($title);
     if ($this->params->get('menu-meta_description')) {
         $this->document->setDescription($this->params->get('menu-meta_description'));
     }
     if ($this->params->get('menu-meta_keywords')) {
         $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
     }
     if ($this->params->get('robots')) {
         $this->document->setMetadata('robots', $this->params->get('robots'));
     }
 }
 public function exportIt($return)
 {
     return parent::exportIt($return);
     $filename = $return['classname'] . "_" . date('Ymd');
     $xls = new Excel($filename);
     //$filename = $return['classname'] . "_" . date('Ymd') . ".xls";
     //header("Content-Disposition: attachment; filename=\"$filename\"");
     //header("Content-Type: application/vnd.ms-excel");
     //$flag = false;
     $xls->home();
     foreach ($return['objs'] as $key => $obj) {
         foreach ($obj as $name => $value) {
             $xls->label(Lang::t($name));
             $xls->right();
         }
         break;
     }
     $xls->down();
     //print("\n");
     foreach ($return['objs'] as $key => $obj) {
         $xls->home();
         foreach ($obj as $name => $value) {
             $xls->label($value);
             $xls->right();
         }
         $xls->down();
     }
     $xls->send();
     exit;
 }
Example #10
0
 /**
  * {@inheritdoc}
  */
 public function read($path)
 {
     if ($this->isFile($path)) {
         return file_get_contents($path);
     }
     throw new FileNotFoundException(\Lang::txt('File does not exist at path %s', $path));
 }
 /**
  * Output the autocompleter
  *
  * @param   string  $what   The component to call
  * @param   string  $name   Name of the input field
  * @param   string  $value  The value of the input field
  * @param   string  $id     ID of the input field
  * @param   string  $class  CSS class(es) for the input field
  * @param   string  $size   The size of the input field
  * @param   string  $wsel   AC autopopulates a select list based on choice?
  * @param   string  $type   Allow single or multiple entries
  * @param   string  $dsabl  Readonly input
  * @return  string
  * @throws  \InvalidArgumentException  If wrong type passed
  */
 public function __invoke($what = null, $name = null, $value = null, $id = null, $class = null, $size = null, $wsel = false, $type = 'multi', $dsabl = false)
 {
     if (!in_array($what, array('tags', 'members', 'groups'))) {
         throw new \InvalidArgumentException(__METHOD__ . '(); ' . \Lang::txt('Autocompleter for "%s" not supported.', $what));
     }
     $id = $id ?: str_replace(array('[', ']'), '', $name);
     switch ($type) {
         case 'multi':
             $event = 'onGetMultiEntry';
             break;
         case 'single':
             $event = 'onGetSingleEntry';
             if ($wsel) {
                 $event = 'onGetSingleEntryWithSelect';
             }
             break;
         default:
             throw new \InvalidArgumentException(__METHOD__ . '(); ' . \Lang::txt('Autocompleter type "%s" not supported.', $type));
             break;
     }
     $results = \Event::trigger('hubzero.' . $event, array(array($what, $name, $id, $class, $value, $size, $wsel, $type, $dsabl)));
     if (count($results) > 0) {
         $results = implode("\n", $results);
     } else {
         $results = '<input type="text" name="' . $name . '" id="' . $id . '" value="' . $value . '" />';
     }
     return $results;
 }
 /**
  * ユーザーにメールを送信
  *
  * @para $name メールの識別子 $params 差し込むデータ $to 送り先(指定しなければ langの値を使用) $options Fuel準拠のEmailオプション
  * @access protected
  * @return bool
  * @author kobayasi
  * @author shimma
  */
 public function sendMailByParams($name, $params = array(), $to = null, $options = null)
 {
     Lang::load("email/{$name}");
     $email = Email::forge();
     $email->from(Lang::get('from'), Lang::get('from_name'));
     $email->subject($this->renderTemplate(Lang::get('subject'), $params, false));
     $email->body($this->renderTemplate(Lang::get('body'), $params));
     if (!$to) {
         $to = Lang::get('email');
     }
     $email->to($to);
     if (Lang::get('bcc') != '') {
         $email->bcc(Lang::get('bcc'));
     }
     if (!empty($options)) {
         foreach ($options as $option => $value) {
             if (empty($value)) {
                 continue;
             }
             switch ($option) {
                 case 'bcc':
                     $email->bcc($value);
                     break;
                 case 'reply_to':
                     $email->reply_to($value);
                     break;
                 case 'subject':
                     $email->subject($value);
                     break;
             }
         }
     }
     return $email->send();
 }
Example #13
0
 public function fetchElement($name, $value, &$node, $control_name)
 {
     require_once dirname(__DIR__) . DS . 'models' . DS . 'poll.php';
     $options = \Components\Poll\Models\Poll::all()->whereEquals('published', 1)->rows()->raw();
     array_unshift($options, \Html::select('option', '0', '- ' . \Lang::txt('Select Poll') . ' -', 'id', 'title'));
     return \Html::select('genericlist', $options, $control_name . '[' . $name . ']', 'class="inputbox"', 'id', 'title', $value, $control_name . $name);
 }
Example #14
0
 public static function lang($string)
 {
     if (static::isLaravel()) {
         return \Lang::get($string);
     }
     return $string;
 }
 public static function get()
 {
     $response = new XMLElement('response');
     foreach (self::$_sections as $section) {
         $section_xml = new XMLElement('section');
         $meta = $section->get();
         foreach ($meta as $key => $value) {
             $section_xml->setAttribute(Lang::createHandle($key), $value);
         }
         $fields = $section->fetchFields();
         foreach ($fields as $field) {
             $meta = $field->get();
             unset($meta['field_id']);
             $field_xml = new XMLElement($meta['element_name'], null);
             foreach (self::$_field_attributes as $attr) {
                 $field_xml->setAttribute(Lang::createHandle($attr), $meta[$attr]);
             }
             foreach ($meta as $key => $value) {
                 if (in_array($key, self::$_field_attributes)) {
                     continue;
                 }
                 $value = General::sanitize($value);
                 if ($value != '') {
                     $field_xml->appendChild(new XMLElement(Lang::createHandle($key), General::sanitize($value)));
                 }
             }
             $section_xml->appendChild($field_xml);
         }
         $response->appendChild($section_xml);
     }
     REST_API::sendOutput($response);
 }
Example #16
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     $state = $this->get('State');
     $canDo = ModulesHelper::getActions();
     Toolbar::title(Lang::txt('COM_MODULES_MANAGER_MODULES'), 'module.png');
     if ($canDo->get('core.create')) {
         //Toolbar::addNew('module.add');
         Toolbar::appendButton('Popup', 'new', 'JTOOLBAR_NEW', 'index.php?option=com_modules&amp;view=select&amp;tmpl=component', 850, 400);
     }
     if ($canDo->get('core.edit')) {
         Toolbar::editList('module.edit');
     }
     if ($canDo->get('core.create')) {
         Toolbar::custom('modules.duplicate', 'copy.png', 'copy_f2.png', 'JTOOLBAR_DUPLICATE', true);
     }
     if ($canDo->get('core.edit.state')) {
         Toolbar::divider();
         Toolbar::publish('modules.publish', 'JTOOLBAR_PUBLISH', true);
         Toolbar::unpublish('modules.unpublish', 'JTOOLBAR_UNPUBLISH', true);
         Toolbar::divider();
         Toolbar::checkin('modules.checkin');
     }
     if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) {
         Toolbar::deleteList('', 'modules.delete', 'JTOOLBAR_EMPTY_TRASH');
         Toolbar::divider();
     } elseif ($canDo->get('core.edit.state')) {
         Toolbar::trash('modules.trash');
         Toolbar::divider();
     }
     if ($canDo->get('core.admin')) {
         Toolbar::preferences('com_modules');
         Toolbar::divider();
     }
     Toolbar::help('modules');
 }
Example #17
0
 public function postLogin()
 {
     if (Request::ajax()) {
         $userdata = array('usuario' => Input::get('usuario'), 'password' => Input::get('password'));
         if (Auth::attempt($userdata, Input::get('remember', 0))) {
             //buscar los permisos de este usuario y guardarlos en sesion
             $query = "SELECT m.nombre as modulo, s.nombre as submodulo,\n                        su.agregar, su.editar, su.eliminar,\n                        CONCAT(m.path,'.', s.path) as path, m.icon\n                        FROM modulos m \n                        JOIN submodulos s ON m.id=s.modulo_id\n                        JOIN submodulo_usuario su ON s.id=su.submodulo_id\n                        WHERE su.estado = 1 AND m.estado = 1 AND s.estado = 1\n                        and su.usuario_id = ?\n                        ORDER BY m.nombre, s.nombre ";
             $res = DB::select($query, array(Auth::id()));
             $menu = array();
             $accesos = array();
             foreach ($res as $data) {
                 $modulo = $data->modulo;
                 //$accesos[] = $data->path;
                 array_push($accesos, $data->path);
                 if (isset($menu[$modulo])) {
                     $menu[$modulo][] = $data;
                 } else {
                     $menu[$modulo] = array($data);
                 }
             }
             $usuario = Usuario::find(Auth::id());
             Session::set('language', 'Español');
             Session::set('language_id', 'es');
             Session::set('menu', $menu);
             Session::set('accesos', $accesos);
             Session::set('perfilId', $usuario['perfil_id']);
             Session::set("s_token", md5(uniqid(mt_rand(), true)));
             Lang::setLocale(Session::get('language_id'));
             return Response::json(array('rst' => '1', 'estado' => Auth::user()->estado));
         } else {
             $m = '<strong>Usuario</strong> y/o la <strong>contraseña</strong>';
             return Response::json(array('rst' => '2', 'msj' => 'El' . $m . 'son incorrectos.'));
         }
     }
 }
Example #18
0
 /**
  * Translates the given string.
  * @param  string	translation string
  * @param  int		count (positive number)
  * @return string
  */
 public function translate($message, $count = 1)
 {
     $message = (string) $message;
     //		if (!empty($message) && isset($this->dictionary[$message])) {
     //			$word = $this->dictionary[$message];
     //			if ($count === NULL) $count = 1;
     //
     //			$s = preg_replace('/([a-z]+)/', '$$1', "n=$count;" . $this->meta['Plural-Forms']);
     //			eval($s);
     //			$message = $word->translate($plural);
     //		}
     if (!isset($this->translate[$message]) or $this->translate[$message] == '') {
         $message = $message;
         //			echo $message;exit;
         if (!dibi::fetchSingle("SELECT 1 FROM [lang_translate] WHERE [key] LIKE %s", $message, "AND [id_lang] = %i", $this->id_lang)) {
             //				echo dibi::$sql;
             Lang::insertTranslateKey($message, $this->id_lang);
         }
         $this->translate[$message] = $message;
         Lang::invalidateCache();
     } else {
         $message = $this->translate[$message];
     }
     //
     //		$args = func_get_args();
     //		if (count($args) > 1) {
     //			array_shift($args);
     //			$message = vsprintf($message, $args);
     //		}
     //
     //
     return $message;
 }
Example #19
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     $state = $this->get('State');
     $canDo = ContentHelper::getActions($this->state->get('filter.category_id'));
     Toolbar::title(Lang::txt('COM_CONTENT_FEATURED_TITLE'), 'featured.png');
     if ($canDo->get('core.create')) {
         Toolbar::addNew('article.add');
     }
     if ($canDo->get('core.edit')) {
         Toolbar::editList('article.edit');
     }
     if ($canDo->get('core.edit.state')) {
         Toolbar::divider();
         Toolbar::publish('articles.publish', 'JTOOLBAR_PUBLISH', true);
         Toolbar::unpublish('articles.unpublish', 'JTOOLBAR_UNPUBLISH', true);
         Toolbar::divider();
         Toolbar::archiveList('articles.archive');
         Toolbar::checkin('articles.checkin');
         Toolbar::custom('featured.delete', 'remove.png', 'remove_f2.png', 'JTOOLBAR_REMOVE', true);
     }
     if ($state->get('filter.published') == -2 && $canDo->get('core.delete')) {
         Toolbar::deleteList('', 'articles.delete', 'JTOOLBAR_EMPTY_TRASH');
         Toolbar::divider();
     } elseif ($canDo->get('core.edit.state')) {
         Toolbar::divider();
         Toolbar::trash('articles.trash');
     }
     if ($canDo->get('core.admin')) {
         Toolbar::preferences('com_content');
         Toolbar::divider();
     }
     Toolbar::help('featured');
 }
Example #20
0
 /**
  * Generate macro output
  *
  * @return     string
  */
 public function render()
 {
     // check if we can render
     if (!parent::canRender()) {
         return \Lang::txt('[This macro is designed for Groups only]');
     }
     // get args
     $args = $this->getArgs();
     // get details
     $type = $this->_getType($args, 'all');
     $limit = $this->_getLimit($args, 5);
     $class = $this->_getClass($args);
     //get resources
     $groupResources = $this->_getResources($type, $limit);
     $html = '<div class="resources ' . $class . '">';
     foreach ($groupResources as $resource) {
         $area = strtolower(preg_replace("/[^a-zA-Z0-9]/", '', $resource->area));
         $resourceLink = \Route::url('index.php?option=com_resources&id=' . $resource->id);
         $resourceTypeLink = \Route::url('index.php?option=com_groups&cn=' . $this->group->get('cn') . '&active=resources&area=' . $area);
         $html .= '<a href="' . $resourceLink . '"><strong>' . $resource->title . '</strong></a>';
         $html .= '<p class="category"> in: <a href="' . $resourceTypeLink . '">' . $resource->area . '</a></p>';
         $html .= '<p>' . \Hubzero\Utility\String::truncate($resource->itext) . '</p>';
     }
     $html .= '</div>';
     return $html;
 }
Example #21
0
 public function editpirepfield()
 {
     $this->set('title', Lang::gs('pirep.field.edit'));
     $this->set('action', 'savefields');
     $this->set('field', PIREPData::GetFieldInfo($this->get->id));
     $this->render('settings_addpirepfield.tpl');
 }
    public function getData()
    {
        //return 'kfjhje';
        return Datatable::collection(Category::All())->searchColumns('name')->orderColumns('name', 'description')->addColumn('name', function ($model) {
            return $model->name;
        })->addColumn('Created', function ($model) {
            $t = $model->created_at;
            return TicketController::usertimezone($t);
        })->addColumn('Actions', function ($model) {
            //return '<a href=category/delete/' . $model->id . ' class="btn btn-danger btn-flat">Delete</a>&nbsp;<a href=category/' . $model->id . '/edit class="btn btn-warning btn-flat">Edit</a>&nbsp;<a href=article-list class="btn btn-warning btn-flat">View</a>';
            return '<span  data-toggle="modal" data-target="#deletecategory' . $model->slug . '"><a href="#" ><button class="btn btn-danger btn-xs"></a>' . \Lang::get("lang.delete") . '</button></span>&nbsp;<a href=category/' . $model->id . '/edit class="btn btn-warning btn-xs">' . \Lang::get("lang.edit") . '</a>&nbsp;<a href=article-list class="btn btn-primary btn-xs">' . \Lang::get("lang.view") . '</a>
				<div class="modal fade" id="deletecategory' . $model->slug . '">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">Are You Sure ?</h4>
                </div>
                <div class="modal-body">
                	' . $model->name . '
                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
                    <a href="category/delete/' . $model->id . '"><button class="btn btn-danger">delete</button></a>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div>';
        })->make();
    }
Example #23
0
 /**
  * Test for Lang::set()
  *
  * @test
  */
 public function test_set()
 {
     Lang::set('testing_set_valid', 'Ahoy :name!');
     $output = Lang::get('testing_set_valid', array('name' => 'Bob'));
     $expected = 'Ahoy Bob!';
     $this->assertEquals($expected, $output);
 }
 public function getLabel()
 {
     $str_year = date('Y', strtotime($this->date_start));
     $str_month_start = ucfirst(Lang::_(strtolower(date('F', strtotime($this->date_start)))));
     $str_month_end = ucfirst(Lang::_(strtolower(date('F', strtotime($this->date_end)))));
     return $str_year . ' ' . $str_month_start . ' - ' . $str_month_end;
 }
Example #25
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     Request::setVar('hidemainmenu', true);
     $isNew = $this->item->id == 0;
     $canDo = TemplatesHelper::getActions();
     Toolbar::title($isNew ? Lang::txt('COM_TEMPLATES_MANAGER_ADD_STYLE') : Lang::txt('COM_TEMPLATES_MANAGER_EDIT_STYLE'), 'thememanager');
     // If not checked out, can save the item.
     if ($canDo->get('core.edit')) {
         Toolbar::apply('style.apply');
         Toolbar::save('style.save');
     }
     // If an existing item, can save to a copy.
     if (!$isNew && $canDo->get('core.create')) {
         Toolbar::save2copy('style.save2copy');
     }
     if (empty($this->item->id)) {
         Toolbar::cancel('style.cancel');
     } else {
         Toolbar::cancel('style.cancel', 'JTOOLBAR_CLOSE');
     }
     Toolbar::divider();
     // Get the help information for the template item.
     $lang = Lang::getRoot();
     $help = $this->get('Help');
     if ($lang->hasKey($help->url)) {
         $debug = $lang->setDebug(false);
         $url = Lang::txt($help->url);
         $lang->setDebug($debug);
     } else {
         $url = null;
     }
     Toolbar::help('style');
     //$help->key, false, $url);
 }
Example #26
0
 /**
  * Parse the URL parameters and map each parameter (in order) to the given array of names
  *
  * @param		array varNames: Array of names to map the URL parameters to
  * @return		object: Object with properties named after var names mapped to URL parameters
  */
 protected function getParams($varNames)
 {
     $i = 0;
     // Strict processing doesn't allow extra or missing parameters in the URL
     $strictProcessing = false;
     $params = false;
     // check if there are more parameters than needed
     $extraParameter = Request::getVar('p' . count($varNames), '');
     if ($strictProcessing && !empty($extraParameter)) {
         // too many parameters in the URL
         //throw new \Exception('Too many parameters');
         App::abort(404, Lang::txt('Page Not Found'));
     }
     // Go through each var name and assign a sequential URL parameter's value to it
     foreach ($varNames as $varName) {
         $value = Request::getVar('p' . $i, '');
         if (!empty($value)) {
             $params->{$varName} = $value;
         } else {
             if ($strictProcessing) {
                 // missing parameter in the URL
                 //throw new \Exception('Too few parameters');
                 App::abort(404, Lang::txt('Page Not Found'));
             }
             break;
         }
         $i++;
     }
     return $params;
 }
Example #27
0
 /**
  * Method to set the publishing state for a row or list of rows in the database
  * table.  The method respects checked out rows by other users and will attempt
  * to checkin rows that it can after adjustments are made.
  *
  * @param	mixed	An optional array of primary key values to update.  If not
  *					set the instance property value is used.
  * @param	integer The publishing state. eg. [0 = unpublished, 1 = published]
  * @param	integer The user id of the user performing the operation.
  * @return	boolean	True on success.
  * @since	1.6
  */
 public function publish($pks = null, $state = 1, $userId = 0)
 {
     // Initialise variables.
     $k = $this->_tbl_key;
     // Sanitize input.
     \Hubzero\Utility\Arr::toInteger($pks);
     $userId = (int) $userId;
     $state = (int) $state;
     // If there are no primary keys set check to see if the instance key is set.
     if (empty($pks)) {
         if ($this->{$k}) {
             $pks = array($this->{$k});
         } else {
             $this->setError(Lang::txt('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
             return false;
         }
     }
     // Build the WHERE clause for the primary keys.
     $where = $k . ' IN (' . implode(',', $pks) . ')';
     // Update the publishing state for rows with the given primary keys.
     $this->_db->setQuery('UPDATE ' . $this->_db->quoteName($this->_tbl) . ' SET ' . $this->_db->quoteName('state') . ' = ' . (int) $state . ' WHERE (' . $where . ')');
     $this->_db->query();
     // Check for a database error.
     if ($this->_db->getErrorNum()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // If the JTable instance value is in the list of primary keys that were set, set the instance.
     if (in_array($this->{$k}, $pks)) {
         $this->state = $state;
     }
     $this->setError('');
     return true;
 }
 public function getLabelsTask()
 {
     $start_index = Get::req('startIndex', DOTY_INT, 0);
     $results = Get::req('results', DOTY_MIXED, Get::sett('visuItem', 25));
     $sort = Get::req('sort', DOTY_MIXED, 'title');
     $dir = Get::req('dir', DOTY_MIXED, 'asc');
     $labels = $this->model->getLabels($start_index, $results, $sort, $dir);
     $total_label = $this->model->getTotalLabelsCount();
     $list = array();
     $first = true;
     $count = count($labels);
     $counter = 0;
     foreach ($labels as $value) {
         $position = "";
         if ($first) {
             $position .= 'first';
             $first = false;
         }
         $counter++;
         if ($counter == $count) {
             $position .= 'last';
         }
         $list[] = array('id_common_label' => $value[LABEL_ID_COMMON], 'title' => $value[LABEL_TITLE], 'description' => $this->_formatDescription($value[LABEL_DESCRIPTION], 100), 'position' => $position, 'sequence' => $value[LABEL_SEQUENCE], 'mod' => '<a href="index.php?r=alms/label/mod&amp;id_common_label=' . $value[LABEL_ID_COMMON] . '" title="' . Lang::t('_MOD', 'label') . '">' . Get::img('standard/edit.png', Lang::t('_MOD', 'label')) . '</a>', 'del' => 'ajax.adm_server.php?r=alms/label/dellabel&id_common_label=' . $value[LABEL_ID_COMMON]);
     }
     $result = array('totalRecords' => $total_label, 'startIndex' => $start_index, 'sort' => $sort, 'dir' => $dir, 'rowsPerPage' => $results, 'results' => count($list), 'records' => $list);
     echo $this->json->encode($result);
 }
Example #29
0
 public static function agregar($input)
 {
     $respuesta = array();
     //Se definen las reglas con las que se van a validar los datos..
     $reglas = array('email' => array('required'));
     //Se realiza la validación
     $validator = Validator::make($input, $reglas);
     if ($validator->fails()) {
         $respuesta['mensaje'] = Lang::get('models.cliente.email_invalido');
         //Si está todo mal, carga lo que corresponde en el mensaje.
         $respuesta['error'] = true;
     } else {
         //Se cargan los datos necesarios para la creacion del Item
         $datos = array('email' => $input['email'], 'fecha_carga' => date("Y-m-d H:i:s"));
         if (isset($input['nombre_apellido'])) {
             $datos['nombre_apellido'] = $input['nombre_apellido'];
         }
         if (isset($input['telefono'])) {
             $datos['telefono'] = $input['telefono'];
         }
         if (isset($input['consulta'])) {
             $datos['consulta'] = $input['consulta'];
         }
         //Lo crea definitivamente
         $cliente = static::create($datos);
         //Mensaje correspondiente a la agregacion exitosa
         $respuesta['mensaje'] = Lang::get('models.cliente.creado');
         $respuesta['error'] = false;
         $respuesta['data'] = $cliente;
     }
     return $respuesta;
 }
 public function importTranslations($replace = false)
 {
     $counter = 0;
     foreach ($this->files->directories($this->app->langPath()) as $langPath) {
         $locale = basename($langPath);
         foreach ($this->files->files($langPath) as $file) {
             $info = pathinfo($file);
             $group = $info['filename'];
             if (in_array($group, $this->config['exclude_groups'])) {
                 continue;
             }
             $translations = \Lang::getLoader()->load($locale, $group);
             if ($translations && is_array($translations)) {
                 foreach (array_dot($translations) as $key => $value) {
                     $value = (string) $value;
                     $translation = Translation::firstOrNew(array('locale' => $locale, 'group' => $group, 'key' => $key));
                     // Check if the database is different then the files
                     $newStatus = $translation->value === $value ? Translation::STATUS_SAVED : Translation::STATUS_CHANGED;
                     if ($newStatus !== (int) $translation->status) {
                         $translation->status = $newStatus;
                     }
                     // Only replace when empty, or explicitly told so
                     if ($replace || !$translation->value) {
                         $translation->value = $value;
                     }
                     $translation->save();
                     $counter++;
                 }
             }
         }
     }
     return $counter;
 }