Esempio n. 1
0
 function __construct(Rubric $rubric = null)
 {
     $this->rubric = $rubric;
     $this->isRubric = !!$rubric;
     if ($this->isRubric) {
         $this->rp = Handlers::getInstance()->getRubricsProcessorByPostType($rubric->getPostType());
         $this->suffix = ' в ' . ps_strtolower($this->rp->rubricTitle(null, 6));
     }
 }
Esempio n. 2
0
 public function getAllRubrics(RubricsBean $bean)
 {
     $rubricTable = $bean->getRubricsTable();
     $rubricsArr = $this->getArray("SELECT * FROM {$rubricTable} r ORDER BY r.name");
     $rubrics = array();
     foreach ($rubricsArr as $data) {
         $rubric = new Rubric($bean->getPostType(), $data);
         $rubrics[$rubric->getId()] = $rubric;
     }
     return $rubrics;
 }
Esempio n. 3
0
 public function edit($id)
 {
     $title = Lang::get('admin/blogs/title.blog_update');
     $post = $this->post->with('rubrics')->find($id);
     $rubrics = \Rubric::all();
     if (is_null($post)) {
         return Redirect::route('admin.blogs.index');
     }
     return View::make('admin/blogs/edit', compact('post', 'title', 'rubrics'));
 }
Esempio n. 4
0
 /**
  * Основной метод, выполняющий построение контроллера для просмотра постов.
  * Контроллер может быть отображен в двух случаях: 
  * 1. На странице с просмотром всех постов
  * 2. На странице с рубрикой
  * 
  * @return ShowcasesControllerPanel
  */
 private function getScPanel($postType, Rubric $rubric = null)
 {
     $key = $postType . '-' . ($rubric ? $rubric->getIdent() : '');
     if (!$this->CACHE->has($key)) {
         $plugins[] = $this->getBaseControllerIdents();
         if ($rubric) {
             $plugins[] = Mappings::RUBRIC_2_SCCONTROLLERS($postType)->getMappedEntitys($rubric->getIdent());
         }
         $insts = $this->getUserAcessibleClassInsts(to_array_expand($plugins));
         $ctxt = new ShowcasesControllerCtxt($rubric);
         $result = array();
         /** @var ShowcasesControllerItem */
         foreach ($insts as $ident => $inst) {
             $inst->doProcess($ctxt);
             $result[$ident] = $inst;
         }
         $this->CACHE->set($key, new ShowcasesControllerPanel($result));
     }
     return $this->CACHE->get($key);
 }
Esempio n. 5
0
 public function show($slug)
 {
     $title = Lang::get('admin/blogs/title.blog_show');
     $post = $this->post->where('slug', $slug)->firstOrFail();
     $rubrics = \Rubric::all();
     // FIXME В mysql RAND()!
     $rubric = $another_posts = $post->rubrics()->first();
     if (!is_null($rubric)) {
         $another_posts = $rubric->posts()->orderBy(DB::raw("RAND()"))->take(4)->get();
     } else {
         $another_posts = [];
     }
     return View::make('blogs/show', compact('post', 'title', 'rubrics', 'another_posts'));
 }
 /**
  * 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 Rubric the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Rubric::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Esempio n. 7
0
 function __construct(Rubric $rubricContent)
 {
     $this->rubricContent = $rubricContent;
     $this->rp = Handlers::getInstance()->getRubricsProcessorByPostType($rubricContent->getPostType());
 }
Esempio n. 8
0
 public function testGet()
 {
     $building = $this->_rubric->get(1);
     $this->assertTrue($building instanceof \consultnn\api\mappers\geo\Building, 'Each value must be instance of Building');
 }
Esempio n. 9
0
 public static function rubrics()
 {
     /* if (mysql_num_rows($result) > 0) {
                  echo("<UL>\n");
                  while ( $row = mysql_fetch_array($result) ) {
                      $ID1 = $row["id"];
                      echo("<LI>\n");
                      echo("<A HREF=\"" . "?ID=" . $ID1 . "\">" . $row["title"] . "</A>" . "&nbsp;&nbsp;\n");
                      ShowTree($ID1, $lvl);
                      $lvl--;
                  }
                  echo("</UL>\n");
              }
     
     
             Array
     (
         [0] => Array
             (
                 [text] =>  История
                 [expanded] => 1
                 [children] => Array
                     (
                         [0] => Array
                             (
                                 [text] =>  Мировая
                                 [expanded] => 1
                             )
     
                         [1] => Array
                             (
                                 [text] =>  Средних веков
                                 [expanded] => 1
                                 [children] => Array
                                     (
                                         [0] => Array
                                             (
                                                 [text] =>  Страны
                                                 [expanded] => 1
                                                 [children] => Array
                                                     (
                                                         [0] => Array
                                                             (
                                                                 [text] =>  Россия
                                                                 [expanded] => 1
                                                             )
     
                                                         [1] => Array
                                                             (
                                                                 [text] =>  Украина
                                                                 [expanded] => 1
                                                             )
     
                                                     )
     
                                             )
     
                                     )
     
                             )
     
                     )
     
             )
     
         [1] => Array
             (
                 [text] =>  Программирование
                 [expanded] => 1
                 [children] => Array
                     (
                         [0] => Array
                             (
                                 [text] => PHP
                                 [expanded] => 1
                             )
     
                         [1] => Array
                             (
                                 [text] => C++
                             )
     
                     )
     
             )
     
     )
     
     
     
     
     
     
             */
     //return (Rubric::model()->findAll());
     $d = array('ch' => 1);
     for ($i = 1; $i < 3; $i++) {
         $d = array('ch' => $d);
     }
     /*        echo "<pre>";
             print_r($d);
             echo "</pre>";
             die();*/
     $k = array();
     $a = array("ch" => 1);
     $a = 'array("ch"=>array("ch"=>1))';
     array_push($k, "dkfdf");
     //$k = array_fill_keys($k, 'banana');
     //$k= $a;
     /*        echo "<pre>";
             print_r($k);
             echo "</pre>";
             die();*/
     $level = 1;
     $rubricArray = array();
     $idArray = array();
     $children = array();
     $i = 0;
     $rubric = Rubric::model()->findAll();
     foreach ($rubric as $rubricEach) {
         $idArray[$rubricEach->level] = 0;
         if ($level == $rubricEach->level) {
             if ($rubricEach->level > 1) {
                 for ($x = 1; $x < $rubricEach->level; $x++) {
                     $children = array('children' => array($idArray[$x] => $children));
                 }
                 $rubricArray = array('children' => array($idArray[$rubricEach->level] => $rubricEach->rubric_title));
                 //$rubricArray[] = array('text' => $rubricEach->rubric_title, 'expanded' => true);
                 $idArray[$rubricEach->level]++;
             } else {
                 $rubricArray[$idArray[$rubricEach->level]] = array('text' => $rubricEach->rubric_title, 'expanded' => true);
                 $idArray[$rubricEach->level]++;
             }
         } else {
             $level++;
             /*                $rubricArray[] = array('text' => $rubricEach->rubric_title, 'expanded' => true);
                             $idArray[$rubricEach->level]++;*/
         }
     }
     echo "<pre>";
     print_r($rubricArray);
     echo "</pre>";
     die;
     return $rubricArray;
 }
Esempio n. 10
0
$cobj = json_decode($cjson);
if ($cobj == null) {
    echo 'fail context';
    echo $cjson;
    die;
}
$cURIs = array();
$newContextsGraph = ARC2::getComponent('PMJ_ResourceGraphPlugin', $config);
foreach ($cobj as $key => $newContextObj) {
    $newContext = new Context($newContextObj);
    $newContext->buildPrivateGraph();
    $newCURI = $newContext->uri;
    $newContextsGraph->mergeResourceGraph($newContext->graph);
    if (in_array($key, $robj->rubricMeta[4]->rContexts)) {
        $cURIs[] = urldecode($newCURI);
    }
}
foreach ($robj->rubricMeta[4]->rContexts as $val) {
    if (substr($val, 0, 3) != 'new') {
        $cURIs[] = urldecode($val);
    }
}
$robj->rubricMeta[4]->rContexts = $cURIs;
//build contexts if needed, and get an array of the context URIs to pass to Rubric
$newRubric = new Rubric($robj, $cURIs);
$newRubric->buildGraph();
//echo $newRubric->graph->toNTriples();
$q = 'INSERT INTO <>  { ' . $newRubric->graph->toNTriples() . ' } ';
$rs = $store->query($q);
$q = 'INSERT INTO <>  { ' . $newContextsGraph->toNTriples() . ' } ';
$rs = $store->query($q);
Esempio n. 11
0
 private function loadRubrics($what, $where = null)
 {
     return $this->getObjects(Query::select($what, $this->rubricsView, $where), null, Rubric::getClass(), 'id_rubric', array($this->getPostType()));
 }
Esempio n. 12
0
 public function index()
 {
     $title = Lang::get('admin/blogs/title.blog_management');
     $rubrics = \Rubric::all();
     return View::make('admin/blogs/rubrics/index', compact('title', 'rubrics'));
 }
Esempio n. 13
0
 private function setRubricData(Rubric $rubric)
 {
     $this->setExtraData('rid', $rubric->getId());
     $this->setExtraData('ptype', $rubric->getPostType());
     $this->setExtraData('rubric');
 }
Esempio n. 14
0
    /**
     * 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 Book the loaded model
     * @throws CHttpException
     */
    public function loadModel($id)
    {
        $model = Book::model()->findByPk($id);
        $rubrics = Rubric::model()->findAllBySql('
		SELECT r.title
		FROM db_rubric AS r
		INNER JOIN db_rubrics_books AS rb
		ON rb.rubric_id = r.id
		WHERE rb.book_id = ' . $id);
        $string = '';
        foreach ($rubrics as $rubric) {
            $string .= $rubric->title . ', ';
        }
        $model['rubric'] = substr($string, 0, strlen($string) - 2);
        unset($string);
        $model['comments'] = Comment::model()->findAllBySql('
		SELECT *
		FROM db_comment AS c
		INNER JOIN db_comments_books AS cb
		ON cb.commnet_id = c.id
		WHERE cb.book_id = ' . $id);
        $model['review'] = Review::model()->findAllBySql('
		SELECT *
		FROM db_review AS r
		INNER JOIN db_reviews_books AS rb
		ON rb.review_id = r.id
		WHERE rb.book_id = ' . $id);
        $model['files'] = Files::model()->findAllBySql('
		SELECT f.type, f.title
		FROM db_files AS f
		WHERE f.book_id = ' . $id);
        if ($model === null) {
            throw new CHttpException(404, 'The requested page does not exist.');
        }
        return $model;
    }