예제 #1
0
 public static function generate($model, $title, $id = null)
 {
     $list = array("job" => array("model" => "Wpjb_Model_Job", "field" => "job_slug"), "type" => array("model" => "Wpjb_Model_JobType", "field" => "slug"), "category" => array("model" => "Wpjb_Model_Category", "field" => "slug"));
     $slug = sanitize_title_with_dashes($title);
     $slug = preg_replace("([^A-z0-9\\-]+)", "", $slug);
     $newSlug = $slug;
     $isUnique = true;
     $query = new Daq_Db_Query();
     $query->select("t." . $list[$model]['field'])->from($list[$model]['model'] . " t")->where("(" . $list[$model]['field'] . " = ?", $newSlug)->orWhere($list[$model]['field'] . " LIKE ? )", $newSlug . "%");
     if ($id > 0) {
         $query->where("id <> ?", $id);
     }
     $field = "t__" . $list[$model]['field'];
     $list = array();
     $c = 0;
     foreach ($query->fetchAll() as $q) {
         $list[] = $q->{$field};
         $c++;
     }
     if ($c > 0) {
         $isUnique = false;
         $i = 1;
         do {
             $i++;
             $newSlug = $slug . "-" . $i;
             if (!in_array($newSlug, $list)) {
                 $isUnique = true;
             }
         } while (!$isUnique);
     }
     return $newSlug;
 }
예제 #2
0
 public static function render()
 {
     $list = new Daq_Db_Query();
     $list->select("t.payment_currency as curr");
     $list->from("Wpjb_Model_Payment t");
     $list->where("payment_paid > 0");
     $list->group("payment_currency");
     $result = $list->fetchAll();
     $curr = array();
     foreach ($result as $r) {
         $c = Wpjb_List_Currency::getCurrency($r->curr);
         $curr[$r->curr] = $c["name"];
     }
     $view = Wpjb_Project::getInstance()->getAdmin()->getView();
     /* @var $view  Daq_View */
     $view->currency = $curr;
     $view->render("dashboard/stats.php");
 }
예제 #3
0
 protected static function _getUniqueSlug($title)
 {
     $slug = sanitize_title_with_dashes($title);
     $newSlug = $slug;
     $isUnique = true;
     $query = new Daq_Db_Query();
     $query->select("t.job_slug")->from("Wpjb_Model_Job t")->where("(t.job_slug = ?", $newSlug)->orWhere("t.job_slug LIKE ? )", $newSlug . "%");
     $list = array();
     $c = 0;
     foreach ($query->fetchAll() as $q) {
         $list[] = $q->t__job_slug;
         $c++;
     }
     if ($c > 0) {
         $isUnique = false;
         $i = 1;
         do {
             $i++;
             $newSlug = $slug . "-" . $i;
             if (!in_array($newSlug, $list)) {
                 $isUnique = true;
             }
         } while (!$isUnique);
     }
     return $newSlug;
 }