Esempio n. 1
0
 function setup()
 {
     parent::setup();
     $app = Prado::getApplication();
     $this->userDao = $app->getModule('daos')->getDao('UserDao');
     $this->flushDatabase();
 }
Esempio n. 2
0
 public function onLoad($param)
 {
     $this->Page->Title = Prado::localize('NewCustomer');
     $this->content->Visible = true;
     $this->reg_ok->Visible = false;
     $this->Save->ImageUrl = $this->Page->Theme->BaseUrl . '/images/' . $this->getApplication()->getGlobalization()->Culture . '/save.gif';
     $this->btnCancelSelect->ImageUrl = $this->Page->Theme->BaseUrl . '/images/' . $this->getApplication()->getGlobalization()->Culture . '/cancel.gif';
     if (isset($_GET["status"])) {
         $this->content->Visible = false;
         $this->reg_ok->Visible = true;
     }
     if ($this->User->UserDB->type_user_id == 4) {
         $this->Save->Visible = false;
         $this->btnCancelSelect->Visible = false;
     } else {
         $this->Save->Visible = true;
         $this->btnCancelSelect->Visible = true;
     }
     $criteria = new TActiveRecordCriteria();
     $criteria->OrdersBy['id'] = 'desc';
     $classifiche = TblClassifica::finder()->findAll($criteria);
     $this->DDLClassifica->DataSource = $classifiche;
     $this->DDLClassifica->dataBind();
     $this->DDLClassifica->SelectedValue = 1;
 }
 protected function getCache()
 {
     if (!$this->_cache) {
         $this->_cache = Prado::getApplication()->getCache();
     }
     return $this->_cache;
 }
 /**
  * Runs the service.
  * This method is invoked by application automatically.
  */
 public function run()
 {
     $id = $this->getRequest()->getServiceParameter();
     if (isset($this->_feeds[$id])) {
         $feedConfig = $this->_feeds[$id];
         $properties = $feedConfig->getAttributes();
         if (($class = $properties->remove('class')) !== null) {
             $feed = Prado::createComponent($class);
             if ($feed instanceof IFeedContentProvider) {
                 // init feed properties
                 foreach ($properties as $name => $value) {
                     $feed->setSubproperty($name, $value);
                 }
                 $feed->init($feedConfig);
                 $content = $feed->getFeedContent();
                 //$this->getResponse()->setContentType('application/rss+xml');
                 $this->getResponse()->setContentType($feed->getContentType());
                 $this->getResponse()->write($content);
             } else {
                 throw new TConfigurationException('feedservice_feedtype_invalid', $id);
             }
         } else {
             throw new TConfigurationException('feedservice_class_required', $id);
         }
     } else {
         throw new THttpException(404, 'feedservice_feed_unknown', $id);
     }
 }
Esempio n. 5
0
 /**
  * @return TWebControlDecorator
  */
 public function getDecorator($create = true)
 {
     if ($create && !$this->_decorator) {
         $this->_decorator = Prado::createComponent('TWebControlDecorator', $this);
     }
     return $this->_decorator;
 }
Esempio n. 6
0
 protected function getData()
 {
     $d = array();
     $cmd = $this->db->createCommand("SELECT * FROM hr_config WHERE id=1");
     $query = $cmd->query();
     $data = $query->read();
     $dir = $data['log_path'];
     if (file_exists($dir)) {
         if (!is_readable($dir)) {
             $this->displayMessage(Prado::localize('The directory {dir} is not readable', array("dir" => $dir)), false);
             return false;
         }
     } else {
         $this->displayMessage(Prado::localize('The directory {dir} does not exist', array("dir" => $dir)), false);
         return false;
     }
     $list = scandir($dir);
     $i = 0;
     foreach ($list as $l) {
         if ($l != "." && $l != "..") {
             $d[$i]['Value'] = "./horuxlog/" . $l;
             $d[$i++]['Text'] = $l;
         }
     }
     return $d;
 }
Esempio n. 7
0
 function insertBrick($sender, $param)
 {
     $x = Prado::createComponent("Application.pages.LTemplate");
     $x->Size = $sender->NamingContainer->findControl("MySize")->SelectedValue;
     $this->placeholder->getControls()->add($x);
     $this->Page->CallbackClient->insertContentAfter($this->AjaxInsertPoint, $x);
 }
 public function displayHardwareList()
 {
     $path = './protected/pages/hardware/device/';
     $files = scandir($path);
     $types = array();
     foreach ($files as $f) {
         if ($f != '..' && $f != '.' && $f != '.svn' && is_dir($path . $f)) {
             $t = explode("_", $f);
             $type = $t;
             unset($type[0]);
             $types[$t[0]][] = implode("_", $type);
         }
     }
     $html = '<ul id="menu-item" class="jtree">';
     foreach ($types as $k => $v) {
         $html .= '<li id="internal-node">';
         $html .= '<div class="node-open"><span></span>';
         $html .= Prado::localize("{type} technology", array('type' => $k));
         $html .= '</div><ul>';
         foreach ($v as $k2 => $v2) {
             $html .= '<li>';
             $html .= '<div class="leaf"><span></span>';
             $html .= '<a href="' . $this->Service->constructUrl('hardware.device.' . $k . '_' . $v2 . '.add') . '">' . $v2 . '</a>';
             $html .= '</div>';
             $html .= '</li>';
         }
         $html .= '</ul>';
         $html .= '</li>';
     }
     $html .= '</ul>';
     return $html;
 }
Esempio n. 9
0
 public function onLoad($param)
 {
     $this->Page->Title = Prado::localize('Confirm');
     $id = 0;
     $code = "";
     if (isset($_GET["id"])) {
         $id = $_GET["id"];
     }
     if (isset($_GET["code"])) {
         $code = $_GET["code"];
     }
     if ($id != 0 && $code != "") {
         $user = TblUsers::finder()->findBy_id($id);
         if ($user != null) {
             if ($user->active == 1) {
                 $this->result->Text = Prado::localize('USER_ALREADY_ACTIVE') . " <a href='mailto:" . $this->Application->Parameters['EMAIL_ASSISTENZE'] . "'>" . Prado::localize('ASSISTENZE') . "</a>";
             } else {
                 if ($user->confirm_code != $code) {
                     $this->result->Text = Prado::localize('USER_WRONG_CODE') . " <a href='mailto:" . $this->Application->Parameters['EMAIL_ASSISTENZE'] . "'>" . Prado::localize('ASSISTENZE') . "</a>";
                 } else {
                     $user->active = 1;
                     $user->save();
                     $this->result->Text = Prado::localize('ACTIVATION_OK');
                 }
             }
         } else {
             $this->result->Text = Prado::localize('USER_NOT_EXIST') . " <a href='mailto:" . $this->Application->Parameters['EMAIL_ASSISTENZE'] . "'>" . Prado::localize('ASSISTENZE') . "</a>";
         }
     } else {
     }
 }
Esempio n. 10
0
 protected function getThumbnailGenerator()
 {
     if (is_null($this->_thumbnailGen)) {
         $this->_thumbnailGen = Prado::createComponent($this->getThumbnailGeneratorClass());
     }
     return $this->_thumbnailGen;
 }
Esempio n. 11
0
 public function editRow($sender, $param)
 {
     if ($this->IsValid) {
         $finder = SliderRecord::finder();
         $finder->DbConnection->Active = true;
         $transaction = $finder->DbConnection->beginTransaction();
         try {
             $rows = $finder->findByID($this->getRequest()->itemAt("id"));
             $rows->Name = TPropertyValue::ensureString($this->Name->getSafeText());
             $rows->Description = TPropertyValue::ensureString($this->Description->getText());
             $rows->save();
             $baseMethod = new BaseFunction();
             $d = dir($baseMethod->UploadFilePath);
             while ($entry = $d->read()) {
                 if (strlen($entry) > 2 && is_file($d->path . '/' . $entry) && $entry != '.htaccess') {
                     $namePhoto = strtolower($entry);
                     $rowPhoto = SliderRecord::finder()->findByID($this->getRequest()->itemAt("id"));
                     $rowPhoto->Photo = $namePhoto;
                     $rowPhoto->save();
                     copy($baseMethod->UploadFilePath . $entry, Prado::getPathOfAlias('UserFiles') . '/Slider/' . $namePhoto) or die("Błąd przy kopiowaniu");
                 }
             }
             $d->close();
             $transaction->commit();
             $this->Response->redirect($this->Service->constructUrl("Slider.Index", array("id" => $this->getRequest()->itemAt("id"))));
         } catch (Exception $e) {
             $transaction->rollBack();
             die;
         }
     }
 }
 /**
  * Creates a new instance of a particular class (for PHP primative types,
  * their corresponding default value for given type is used).
  * @param string PHP type name
  * @return mixed default type value, if no type is specified null is returned.
  * @throws TSqlMapException if class name is not found.
  */
 public function createInstanceOf($type = '')
 {
     if (strlen($type) > 0) {
         switch (strtolower($type)) {
             case 'string':
                 return '';
             case 'array':
                 return array();
             case 'float':
             case 'double':
             case 'decimal':
                 return 0.0;
             case 'integer':
             case 'int':
                 return 0;
             case 'bool':
             case 'boolean':
                 return false;
         }
         if (class_exists('Prado', false)) {
             return Prado::createComponent($type);
         } else {
             if (class_exists($type, false)) {
                 //NO auto loading
                 return new $type();
             } else {
                 throw new TSqlMapException('sqlmap_unable_to_find_class', $type);
             }
         }
     }
 }
Esempio n. 13
0
 protected function getData($offset, $limit)
 {
     $session = Prado::getApplication()->getSession();
     $langID = $session->itemAt('jezyk');
     $this->DataGrid->DataSource = PagesRecord::finder()->findAll('LanguageID = ? AND PageID = 19 ORDER BY Position', $langID);
     return $this->DataGrid->dataBind();
 }
Esempio n. 14
0
 public function onDefault($sender, $param)
 {
     $cbs = $this->findControlsByType("TActiveCheckBox");
     $nDelete = 0;
     $koMsg = '';
     $cbChecked = 0;
     foreach ($cbs as $cb) {
         if ((bool) $cb->getChecked() && $cb->Value != "0") {
             $cbChecked++;
         }
     }
     if ($cbChecked == 0) {
         $koMsg = Prado::localize('Select one item');
     } elseif ($cbChecked == 1) {
         foreach ($cbs as $cb) {
             if ((bool) $cb->getChecked() && $cb->Value != "0") {
                 $cmd = $this->db->createCommand("UPDATE hr_install SET `default`='0' WHERE type='template'");
                 $cmd->execute();
                 $cmd = $this->db->createCommand("UPDATE hr_install SET `default`='1' WHERE id=:id");
                 $cmd->bindValue(":id", $cb->Value);
                 $cmd->execute();
             }
         }
     } else {
         $koMsg = Prado::localize('Select only one item');
     }
     if ($koMsg !== '') {
         $pBack = array('koMsg' => $koMsg);
     } else {
         $pBack = array('okMsg' => Prado::localize('New default template updated'));
     }
     $this->Response->redirect($this->Service->constructUrl('installation.template', $pBack));
 }
 /**
  * Rolls back a transaction.
  * @throws TDbException if the transaction or the DB connection is not active.
  */
 public function rollback()
 {
     if ($this->_compatible) {
         $this->getConnection()->setForceMaster(TMasterSlaveDbConnectionForceMaster::OFF_AUTOMATIC);
     }
     Prado::log('rollback, ForceMaster: OFF_AUTOMATIC', TLogger::DEBUG, 'System.Testing.Data.Distributed.MasterSlave.TMasterSlaveDbTransaction');
     parent::rollback();
 }
Esempio n. 16
0
 public function fileDelete($sender, $param)
 {
     if ($this->pathName[1] == 'Index') {
         FilesRecord::finder()->deleteByID($param->CommandName);
         unlink(Prado::getPathOfAlias('UserFiles') . '/' . $this->pathName[0] . '/' . $this->getRequest()->itemAt("id") . '/' . $param->CommandParameter);
     }
     $this->Response->redirect($this->Service->constructUrl($this->pathName[0] . ".Index", array("id" => $this->getRequest()->itemAt("id"))));
 }
Esempio n. 17
0
 public function getShortLang()
 {
     $source = Prado::getApplication()->getGlobalization();
     if (Prado::getApplication()->getRequest()->contains('culture')) {
         $source->setCulture(Prado::getApplication()->getRequest()->itemAt('culture'));
     }
     return $source->getCulture();
 }
Esempio n. 18
0
 function setup()
 {
     parent::setup();
     $app = Prado::getApplication();
     $this->categoryDao = $app->getModule('daos')->getDao('CategoryDao');
     $this->projectDao = $app->getModule('daos')->getDao('ProjectDao');
     $this->flushDatabase();
 }
Esempio n. 19
0
 function button2_onclick($sender, $param)
 {
     $this->label1->Text = "Button 1 was clicked ";
     $this->label1->Text .= $this->foo->Text;
     $x = Prado::createComponent('Application.pages.CustomTemplateComponent');
     $this->placeholder->getControls()->add($x);
     $this->placeholder->dataBind();
 }
 /**
  * Creates a new instance of TimeTrackerUser
  * @param array result data
  * @return TimeTrackerUser new user instance
  */
 public function createNewInstance($row = null)
 {
     $manager = Prado::getApplication()->getModule('users');
     if (is_null($manager)) {
         $manager = new UserManager();
     }
     return new TimeTrackerUser($manager);
 }
Esempio n. 21
0
 function Footer()
 {
     //Positionnement � 1,5 cm du bas
     $this->SetY(-15);
     //Police Arial italique 8
     $this->SetFont('Arial', 'I', 8);
     //Num�ro de page
     $this->Cell(0, 10, Prado::localize('Page', array(), "messages") . ' ' . $this->PageNo(), 'T', 0, 'C');
 }
Esempio n. 22
0
 /**
  * Handles external error caused by end-users.
  * This method overrides the parent implementation.
  * It is invoked by PRADO when an external exception is thrown.
  */
 protected function handleExternalError($statusCode, $exception)
 {
     // log the error (only for BlogException)
     if ($exception instanceof BlogException) {
         Prado::log($exception->getErrorMessage(), TLogger::ERROR, 'BlogApplication');
     }
     // call parent implementation to display the error
     parent::handleExternalError($statusCode, $exception);
 }
Esempio n. 23
0
 private function _startThemeManager()
 {
     $themeManager = new TThemeManager();
     $themeManager->BasePath = "System.Wsat.themes";
     $url = Prado::getApplication()->getAssetManager()->publishFilePath(Prado::getPathOfNamespace('System.Wsat'));
     $themeManager->BaseUrl = "{$url}/themes";
     $themeManager->init(null);
     $this->setThemeManager($themeManager);
 }
Esempio n. 24
0
 function onLoad($param)
 {
     new TActiveButton();
     for ($i = 0; $i < 1500; $i++) {
         $ctl = Prado::createComponent("TLabel");
         $ctl->Text = "Label " . $i;
         $this->Controls[] = $ctl;
     }
 }
Esempio n. 25
0
 /**
  * @return string path to the error message file
  */
 protected function getErrorMessageFile()
 {
     $lang = Prado::getPreferredLanguage();
     $msgFile = Prado::getFrameworkPath() . '/Exceptions/messages/messages-' . $lang . '.txt';
     if (!is_file($msgFile)) {
         $msgFile = Prado::getFrameworkPath() . '/Exceptions/messages/messages.txt';
     }
     return $msgFile;
 }
Esempio n. 26
0
 protected function getZendSearch()
 {
     if (is_null($this->_search)) {
         $this->importZendNamespace();
         Prado::using('Zend.Search.Lucene');
         $this->_search = new Zend_Search_Lucene($this->_data);
     }
     return $this->_search;
 }
Esempio n. 27
0
 public function editRow($sender, $param)
 {
     if ($this->IsValid) {
         $short = strtolower($this->ShortName->getSafeText());
         $rows = new CatalogueRecord();
         $rows->name = 'messages.' . $short;
         $rows->MasterName = TPropertyValue::ensureString($this->Name->getSafeText());
         $rows->ShortName = TPropertyValue::ensureString($short);
         $rows->save();
         if (!is_dir(Prado::getPathOfAlias('UserFiles') . '/Language/' . $rows->cat_id)) {
             $dirun = dir(Prado::getPathOfAlias('UserFiles'));
             mkdir($dirun->path . '/Language/' . $rows->cat_id, 0775);
             $dirun->close();
         }
         $baseMethod = new BaseFunction();
         $d = dir($baseMethod->UploadFilePath);
         while ($entry = $d->read()) {
             if (strlen($entry) > 2 && is_file($d->path . '/' . $entry) && $entry != '.htaccess') {
                 copy($baseMethod->UploadFilePath . $entry, Prado::getPathOfAlias('UserFiles') . '/Language/' . $rows->cat_id . '/' . $entry) or die("Błąd przy kopiowaniu");
                 $row = CatalogueRecord::finder()->findBycat_id($rows->cat_id);
                 $row->Photo = $entry;
                 $row->save();
             }
         }
         $statyczne = PagesRecord::finder()->findAll('PageID IS NULL AND LanguageID = 1');
         foreach ($statyczne as $page) {
             $new = new PagesRecord();
             $new->Name = $rows->ShortName . ' : ' . $page->Name;
             $new->LanguageID = $rows->cat_id;
             $new->LangCode = $short;
             $new->PageID = $page->PageID;
             $new->Protected = $page->Protected;
             $new->Position = $page->Position;
             $new->ShowMenu = $page->ShowMenu;
             $new->save();
         }
         $translation = TransUnitRecord::finder()->findAll('cat_id = 1');
         foreach ($translation as $page) {
             $new = new TransUnitRecord();
             $new->id = $page->id;
             $new->cat_id = $rows->cat_id;
             $new->source = $page->source;
             $new->save();
         }
         $settings = SettingsRecord::finder()->findAll('LanguageID = 1');
         foreach ($settings as $set) {
             $newS = new SettingsRecord();
             $newS->Key = $set->Key;
             $newS->Value = $rows->ShortName . ' : ' . $set->Value;
             $newS->LanguageID = $rows->cat_id;
             $newS->LangCode = $short;
             $newS->save();
         }
         $this->Response->redirect($this->Service->constructUrl("Language.Index", array('id' => $rows->cat_id)));
     }
 }
Esempio n. 28
0
 /**
  * Sets the location of image file of the THyperLink.
  * @param string the image file location
  */
 public function setImageUrl($value)
 {
     parent::setImageUrl($value);
     if ($this->getActiveControl()->canUpdateClientSide() && $value !== '') {
         $textWriter = new TTextWriter();
         $renderer = Prado::createComponent($this->GetResponse()->getHtmlWriterType(), $textWriter);
         $this->createImage($value)->renderControl($renderer);
         $this->getPage()->getCallbackClient()->update($this, $textWriter->flush());
     }
 }
Esempio n. 29
0
 function flushMySQLDatabase()
 {
     $conn = $this->sqlmap->getDbConnection();
     $file = Prado::getPathOfNamespace('Application.App_Data.MySQL4.mysql-reset', '.sql');
     if (is_file($file)) {
         $this->runScript($conn, $file);
     } else {
         throw new Exception('unable to find script file ' . $file);
     }
 }
Esempio n. 30
0
 /**
  * @return string path to the error message file
  */
 protected function getErrorMessageFile()
 {
     $lang = Prado::getPreferredLanguage();
     $path = dirname(__FILE__);
     $msgFile = $path . '/messages-' . $lang . '.txt';
     if (!is_file($msgFile)) {
         $msgFile = $path . '/messages.txt';
     }
     return $msgFile;
 }