]> _ Git - fluidbook-v3.git/commitdiff
wip #3375 @3
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 20 Feb 2020 18:25:39 +0000 (18:25 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 20 Feb 2020 18:25:39 +0000 (18:25 +0000)
framework/application/configs/application.ini
framework/application/models/Reference.php

index 1bcb6e0af427201efc12dcbe47ca664b3ed59f72..18a7940a5f4bdf750b42a3e5874e9562b71f9346 100644 (file)
@@ -1,5 +1,5 @@
 [production]
-dev = false
+dev = true
 
 firephp = true
 minify.js = true
index 24a43a5092908829a37010b50256c5446087c4d4..e372a8542d03049193b665722f6db958dabef66f 100644 (file)
 <?php\r
 \r
 \r
-class Fluidbook_Model_Reference extends CubeIT_Model_Data_Table {\r
-       protected static $_table = 'exemples';\r
-\r
-       protected $title;\r
-       protected $text;\r
-       protected $date;\r
-       protected $url;\r
-       protected $fluidbook_id;\r
-       protected $fluidbook_page;\r
-       protected $image;\r
-       protected $categories;\r
-       protected $featured_categories;\r
-       protected $homeimage;\r
-\r
-       protected $_types = array('categories' => 'list', 'featured_categories' => 'list', 'title' => 'json', 'text' => 'json', 'image' => 'json', 'homeimage' => 'json', 'fluidbook_id' => 'json', 'fluidbook_page' => 'json');\r
-\r
-       public static function getSchema($schema) {\r
-               $table = parent::getSchema($schema);\r
-               $table->addColumn('title', 'text');\r
-               $table->addColumn('text', 'text');\r
-               $table->addColumn('url', 'text');\r
-               $table->addColumn('date', 'date');\r
-               $table->addColumn('fluidbook_id', 'text');\r
-               $table->addColumn('fluidbook_page', 'string', array("default" => '{"fr":2,"en":0}', "length" => 128));\r
-               $table->addColumn('featured', 'boolean');\r
-               $table->addColumn('image', 'string', array('length' => 64));\r
-               $table->addColumn('homeimage', 'string', array('length' => 64));\r
-               $table->addColumn('categories', 'string', array('length' => 64));\r
-               $table->addColumn('featured_categories', 'string', array('length' => 64));\r
-               return $table;\r
-       }\r
-\r
-       public function getFluidbookId() {\r
-               $res = parent::getFluidbookId();\r
-               return $this->_setFrDefault($res);\r
-       }\r
-\r
-       protected function _setFrDefault($res) {\r
-\r
-               if (CubeIT_Util_Json::isJson($res)) {\r
-                       $res = CubeIT_Util_Json::decode($res);\r
-               }\r
-\r
-               if (!is_array($res) && !is_object($res)) {\r
-                       return $res;\r
-               }\r
-               $res = CubeIT_Util_Object::asObject($res);\r
-\r
-               if (!$res->en) {\r
-                       $res->en = $res->fr;\r
-               }\r
-\r
-               return $res;\r
-       }\r
-\r
-       protected function _getFinalURL($url, $locale = null) {\r
-               $append = '';\r
-               if ($url) {\r
-                       if (substr($url, 0, 1) == '#') {\r
-                               $append = $url;\r
-                       } else {\r
-                               return $url;\r
-                       }\r
-\r
-               }\r
-               if (null === $locale) {\r
-                       return $this->_getLocalReference($this->getFluidbookId()) . $append;\r
-               } else {\r
-                       return $this->_getLocalReference($this->getFluidbookId()->$locale) . $append;\r
-               }\r
-       }\r
-\r
-       protected function _getLocalReference($id) {\r
-               $dirs = CubeIT_Files::getDirectoryIterator(PUBLIC_PATH . '/references');\r
-               $d = null;\r
-               foreach ($dirs as $dir) {\r
-                       if (!$dir->isDir()) {\r
-                               continue;\r
-                       }\r
-                       $e = explode('-', $dir->getBasename(), 2);\r
-                       if ($e[0] == $id && $e[1] != '') {\r
-                               $d = $dir->getBasename();\r
-                               break;\r
-                       }\r
-               }\r
-               if (null === $d) {\r
-                       return;\r
-               }\r
-\r
-               return '/references/' . $d . '/';\r
-       }\r
-\r
-       public function getFluidbookPage() {\r
-               $res = parent::getFluidbookPage();\r
-               return $this->_setFrDefault($res);\r
-       }\r
-\r
-       public function getFinalUrl() {\r
-               $res = parent::getUrl();\r
-\r
-               $res = $this->_setFrDefault($res);\r
-\r
-               if (!is_array($res) && !is_object($res)) {\r
-                       return $this->_getFinalURL($res);\r
-               }\r
-\r
-               $res->fr = $this->_getFinalURL($res->fr, 'fr');\r
-               $res->en = $this->_getFinalURL($res->en, 'en');\r
-\r
-               return $res;\r
-       }\r
-\r
-       public function hasUrl() {\r
-               $furl = $this->getFinalUrl();\r
-               return $furl && $furl != '-';\r
-       }\r
+class Fluidbook_Model_Reference extends CubeIT_Model_Data_Table\r
+{\r
+    protected static $_table = 'exemples';\r
+\r
+    protected $title;\r
+    protected $text;\r
+    protected $date;\r
+    protected $url;\r
+    protected $fluidbook_id;\r
+    protected $fluidbook_page;\r
+    protected $image;\r
+    protected $categories;\r
+    protected $featured_categories;\r
+    protected $homeimage;\r
+\r
+    protected $_types = array('categories' => 'list', 'featured_categories' => 'list', 'title' => 'json', 'text' => 'json', 'image' => 'json', 'homeimage' => 'json', 'fluidbook_id' => 'json', 'fluidbook_page' => 'json');\r
+\r
+    public static function getSchema($schema)\r
+    {\r
+        $table = parent::getSchema($schema);\r
+        $table->addColumn('title', 'text');\r
+        $table->addColumn('text', 'text');\r
+        $table->addColumn('url', 'text');\r
+        $table->addColumn('date', 'date');\r
+        $table->addColumn('fluidbook_id', 'text');\r
+        $table->addColumn('fluidbook_page', 'string', array("default" => '{"fr":2,"en":0}', "length" => 128));\r
+        $table->addColumn('featured', 'boolean');\r
+        $table->addColumn('image', 'string', array('length' => 64));\r
+        $table->addColumn('homeimage', 'string', array('length' => 64));\r
+        $table->addColumn('categories', 'string', array('length' => 64));\r
+        $table->addColumn('featured_categories', 'string', array('length' => 64));\r
+        return $table;\r
+    }\r
+\r
+    public function getFluidbookId()\r
+    {\r
+        $res = parent::getFluidbookId();\r
+        return $this->_setFrDefault($res);\r
+    }\r
+\r
+    protected function _setFrDefault($res)\r
+    {\r
+\r
+        if (CubeIT_Util_Json::isJson($res)) {\r
+            $res = CubeIT_Util_Json::decode($res);\r
+        }\r
+\r
+        if (!is_array($res) && !is_object($res)) {\r
+            return $res;\r
+        }\r
+        $res = CubeIT_Util_Object::asObject($res);\r
+\r
+\r
+        if (!isset($res->fr)) {\r
+            $res->fr = '';\r
+        }\r
+\r
+        if (!isset($res->en) || !$res->en) {\r
+            $res->en = $res->fr;\r
+        }\r
+\r
+        return $res;\r
+    }\r
+\r
+    protected function _getFinalURL($url, $locale = null)\r
+    {\r
+        $append = '';\r
+        if ($url) {\r
+            if (substr($url, 0, 1) == '#') {\r
+                $append = $url;\r
+            } else {\r
+                return $url;\r
+            }\r
+\r
+        }\r
+        if (null === $locale) {\r
+            return $this->_getLocalReference($this->getFluidbookId()) . $append;\r
+        } else {\r
+            return $this->_getLocalReference($this->getFluidbookId()->$locale) . $append;\r
+        }\r
+    }\r
+\r
+    protected function _getLocalReference($id)\r
+    {\r
+        $dirs = CubeIT_Files::getDirectoryIterator(PUBLIC_PATH . '/references');\r
+        $d = null;\r
+        foreach ($dirs as $dir) {\r
+            if (!$dir->isDir()) {\r
+                continue;\r
+            }\r
+            $e = explode('-', $dir->getBasename(), 2);\r
+            if ($e[0] == $id && $e[1] != '') {\r
+                $d = $dir->getBasename();\r
+                break;\r
+            }\r
+        }\r
+        if (null === $d) {\r
+            return;\r
+        }\r
+\r
+        return '/references/' . $d . '/';\r
+    }\r
+\r
+    public function getFluidbookPage()\r
+    {\r
+        $res = parent::getFluidbookPage();\r
+        return $this->_setFrDefault($res);\r
+    }\r
+\r
+    public function getFinalUrl()\r
+    {\r
+        $res = parent::getUrl();\r
+\r
+        $res = $this->_setFrDefault($res);\r
+\r
+        if (!is_array($res) && !is_object($res)) {\r
+            return $this->_getFinalURL($res);\r
+        }\r
+\r
+        $res->fr = $this->_getFinalURL($res->fr, 'fr');\r
+        $res->en = $this->_getFinalURL($res->en, 'en');\r
+\r
+        return $res;\r
+    }\r
+\r
+    public function hasUrl()\r
+    {\r
+        $furl = $this->getFinalUrl();\r
+        return $furl && $furl != '-';\r
+    }\r
 }
\ No newline at end of file