Example #1
0
 /**
  * Delete a category. Only delete a category if it is not protected
  */
 public function delete()
 {
     // Get any articles using this category
     $articles = News::fetchIdsFrom("category", $this->getId(), 'i');
     // Only delete a category if it is not protected and is not being used
     if (!$this->isProtected() && count($articles) == 0) {
         parent::delete();
     }
 }
Example #2
0
 /**
  * Get the home page
  * @return Page
  */
 public static function getHomePage()
 {
     return Page::get(parent::fetchIdFrom(1, "home"));
 }
 public static function rewrite_file_alias()
 {
     $aliasModel = new AliasModel();
     //  Debugger::PrintR($aliasModel->getAliasDate());
     $date = '<?php' . PHP_EOL . '$url_alias = array(' . PHP_EOL;
     foreach ($aliasModel->getAliasDate() as $k => $v) {
         $date .= '' . PHP_EOL . '      ' . $k . ' => array(' . PHP_EOL;
         foreach ($v as $key => $val) {
             $date .= "            '" . $key . "' => '" . $val . "'," . PHP_EOL;
         }
         $date .= '      ),' . PHP_EOL . '';
     }
     $date .= ');';
     self::rewrite_file(LIB_DIR . 'alias.php', 'w', $date);
 }