public function up()
 {
     $records = array(array('url' => '/survey/activeIndex', 'title' => 'Активные проекты', 'content' => '', 'deletable' => false), array('url' => '/survey/nonActiveIndex', 'title' => 'Завершённые проекты', 'content' => '', 'deletable' => false), array('url' => '/our-power', 'title' => 'Наши мощности', 'content' => '', 'deletable' => false), array('url' => '/excursion-by-offices', 'title' => 'Экскурсия по офисам', 'content' => '', 'deletable' => false), array('url' => '/special-offers', 'title' => 'Акции и спецпредложения', 'content' => '', 'deletable' => false), array('url' => '/fun-moments', 'title' => 'Забавные моменты нашей работы', 'content' => '', 'deletable' => false), array('url' => '/avtozvonok', 'title' => 'Avtozvonok.com', 'content' => '', 'deletable' => false), array('url' => '/low-budget-investigations', 'title' => 'Малобюджетные исследования', 'content' => '', 'deletable' => false));
     foreach ($records as $record) {
         $page = new SimplePage();
         $page->setAttributes($record);
         $page->save();
     }
 }
Пример #2
0
 /**
  * Custom Route parsing for SimplePages URL
  * 
  * @param string $url URL to parse
  */
 function parse($url)
 {
     $params = parent::parse($url);
     if (empty($params)) {
         return false;
     }
     $slugs = Cache::read('simple_page_slugs');
     if (empty($slugs)) {
         App::import('Model', 'SimplePages.SimplePage');
         $SimplePage = new SimplePage();
         $slugs = $SimplePage->cacheSlugs();
     }
     if (isset($params['slug']) && in_array($params['slug'], $slugs)) {
         return $params;
     }
     return false;
 }
Пример #3
0
 /**
  *    Marker for end of complete page. Any work in
  *    progress can now be closed.
  *    @access public
  */
 protected function acceptPageEnd()
 {
     while (count($this->open_forms)) {
         $this->complete_forms[] = array_pop($this->open_forms);
     }
     foreach ($this->left_over_labels as $label) {
         for ($i = 0, $count = count($this->complete_forms); $i < $count; $i++) {
             $this->complete_forms[$i]->attachLabelBySelector(new SimpleById($label->getFor()), $label->getText());
         }
     }
     $this->page->setForms($this->complete_forms);
     $this->page->setFrames($this->loading_frames);
 }
Пример #4
0
 public function actionLogin()
 {
     if (!Yii::app()->user->isGuest) {
         $this->redirect(array('/'));
     }
     $this->layout = 'login';
     $model = new LoginForm();
     // if it is ajax validation request
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     // collect user input data
     if (isset($_POST['LoginForm'])) {
         $model->attributes = $_POST['LoginForm'];
         // validate user input and redirect to the previous page if valid
         if ($model->validate() && $model->login()) {
             $this->redirect(Yii::app()->user->returnUrl);
         }
     }
     // display the login form
     $this->render('login', array('model' => $model, 'simplePage' => SimplePage::model()->findByAttributes(array('url' => '/cabinet/login'))));
 }
Пример #5
0
 /**
  *    Finds links with class.
  *    @param string $class    class value.
  *    @return array/boolean   URLs on success.
  *    @access public
  */
 function getLinksByClass($class)
 {
     return $this->page->getUrlsByClass($class);
 }
Пример #6
0
 /**
  *    Accessor for plain text of page as a text browser
  *    would see it.
  *    @return string        Plain text of page.
  *    @access public
  */
 function getText()
 {
     if (!$this->text) {
         $this->text = SimplePage::normalise($this->raw);
     }
     return $this->text;
 }
Пример #7
0
 function testEmptyPage()
 {
     $page = new SimplePage(new MockSimpleHttpResponse());
     $this->assertIdentical($page->getUrls(), array());
     $this->assertIdentical($page->getTitle(), false);
 }
Пример #8
0
 /**
  *  Visits the given node and all children
  *  @param object $node      Tidy XML node.
  */
 private function walkForm($node, $form, $enclosing_label = '')
 {
     if ($node->name == 'a') {
         $this->page->addLink($this->tags()->createTag($node->name, (array) $node->attribute)->addContent($this->innerHtml($node)));
     } elseif (in_array($node->name, array('input', 'button', 'textarea', 'select'))) {
         $this->addWidgetToForm($node, $form, $enclosing_label);
     } elseif ($node->name == 'label') {
         $this->labels[] = $this->tags()->createTag($node->name, (array) $node->attribute)->addContent($this->innerHtml($node));
         if ($node->hasChildren()) {
             foreach ($node->child as $child) {
                 $this->walkForm($child, $form, SimplePage::normalise($this->innerHtml($node)));
             }
         }
     } elseif ($node->hasChildren()) {
         foreach ($node->child as $child) {
             $this->walkForm($child, $form);
         }
     }
     return $form;
 }
Пример #9
0
 function testUtf8WhitespaceNbsp()
 {
     $this->assertEqual(SimplePage::normalise(' § ' . html_entity_decode('&nbsp;', ENT_COMPAT, 'UTF-8') . '729', 'UTF-8'), '§ 729');
     $this->assertEqual(SimplePage::normalise(html_entity_decode('&nbsp;', ENT_COMPAT, 'UTF-8'), 'UTF-8'), '');
     $this->assertEqual(strlen(SimplePage::normalise(html_entity_decode('a&nbsp;b', ENT_COMPAT, 'UTF-8'), 'UTF-8')), 3);
     $this->assertEqual(strlen(SimplePage::normalise(html_entity_decode('a&nbsp; b', ENT_COMPAT, 'ISO-8859-1'), 'ISO-8859-1')), 3);
     $this->assertEqual(SimplePage::normalise('&raquo; &raquo;', 'UTF-8'), '» »');
     $this->assertEqual(SimplePage::normalise('&raquo; &raquo;', 'ISO-8859-1'), utf8_decode('» »'));
     # latin1 strings should not get converted to utf8
     $this->assertEqual(strlen(SimplePage::normalise(utf8_decode('ä'))), 1);
 }
Пример #10
0
 public function display()
 {
     http_response_code($this->type === static::MISSING_PAGE_ERROR_TYPE ? 404 : 500);
     parent::display();
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return SimplePage the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = SimplePage::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #12
0
 public function actionNonActiveIndex()
 {
     if (!Yii::app()->user->checkAccess('survey.nonActiveIndex')) {
         throw new Http403Exception();
     }
     $dataProvider = LimeSurveyLocal::model()->search();
     $criteria = new CDbCriteria();
     $scopes = LimeSurveyLocal::model()->scopes();
     $criteria->addCondition($scopes['nonActive']['condition']);
     if (!Yii::app()->user->checkAccess('survey.index')) {
         $surveyIdsByLocation = array();
         foreach (Yii::app()->user->userModel->surveyUsers as $relation) {
             if (!isset($surveyIdsByLocation[$relation->surveyLocation])) {
                 $surveyIdsByLocation[$relation->surveyLocation] = array();
             }
             $surveyIdsByLocation[$relation->surveyLocation][] = $relation->surveyId;
         }
         $condition = array();
         foreach ($surveyIdsByLocation as $location => $surveyIds) {
             if (!empty($surveyIds)) {
                 $condition[] = "(t.sid in (" . implode(',', $surveyIds) . ") AND :className = '{$location}')";
             }
         }
         if (!empty($condition)) {
             $criteria->addCondition(implode(" OR ", $condition));
         } else {
             $criteria->addCondition("FALSE");
         }
     }
     $dataProvider->setCriteria($criteria);
     $this->render("nonActiveIndex", array('simplePage' => SimplePage::model()->findByAttributes(array('url' => '/survey/nonActiveIndex')), 'dataProvider' => $dataProvider));
 }
Пример #13
0
    width: 560px;
}

/* Use default styles included with the package */

<?php 
        if ('@data_dir@' != '@' . 'data_dir@') {
            $filename = '@data_dir@/HTML_QuickForm2/quickform.css';
        } else {
            $filename = dirname(dirname(dirname(__FILE__))) . '/data/quickform.css';
        }
        readfile($filename);
        ?>
    </style>
    <title>HTML_QuickForm2 simple controller example</title>
  </head>
  <body>
<?php 
        echo $form;
        ?>
  </body>
</html>
<?php 
    }
}
$page = new SimplePage(new HTML_QuickForm2('page1'));
$page->addHandler('process', new SimpleProcess());
$page->addHandler('display', new SimpleDisplay());
$controller = new HTML_QuickForm2_Controller('Simple');
$controller->addPage($page);
$controller->run();
Пример #14
0
 public function display()
 {
     header('HTTP', true, 500);
     parent::display();
 }
 public function safeUp()
 {
     $page = new SimplePage();
     $page->setAttributes(array('url' => '/cabinet/login', 'title' => '', 'content' => '', 'deletable' => false));
     $page->save();
 }
Пример #16
0
 function testHtmlEntityTranslation()
 {
     $this->assertEqual(SimplePage::normalise('&lt;&gt;&quot;&amp;&#039;'), '<>"&\'');
 }
Пример #17
0
 /**
  *    Accessor for content reduced to visible text. Acts
  *    like a text mode browser, normalising space and
  *    reducing images to their alt text.
  *    @return string       Content as plain text.
  *    @access public
  */
 function getText()
 {
     return SimplePage::normalise($this->content);
 }
Пример #18
0
 /**
  *    Accessor for raw page information.
  *    @return string      Original text content of web page.
  *    @access public
  */
 function getContent()
 {
     return $this->page->getRaw();
 }